From 30c872e5fc09596c6f7c61a6955842d124f85f59 Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Thu, 1 Apr 2021 22:18:29 +0100 Subject: [PATCH] LoadCredentials: do not assert on invalid syntax LoadCredentials=foo causes an assertion to be triggered, as we are not checking that the rvalue's right hand side part is non-empty before using it in unit_full_printf. Fixes #19178 # printf [Service]nLoadCredential=passwd.hashed-password.rootn > hello.service # systemd-analyze verify ./hello.service ... Assertion 'format' failed at src/core/unit-printf.c:232, function unit_full_printf(). Aborting. Aborted (core dumped) --- src/core/load-fragment.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c index c6fc4fe083..6d3bbd4a39 100644 --- a/src/core/load-fragment.c +++ b/src/core/load-fragment.c @@ -4592,7 +4592,7 @@ int config_parse_load_credential( r = extract_first_word(&p, &word, ":", EXTRACT_DONT_COALESCE_SEPARATORS); if (r == -ENOMEM) return log_oom(); - if (r <= 0) { + if (r <= 0 || isempty(p)) { log_syntax(unit, LOG_WARNING, filename, line, r, "Invalid syntax, ignoring: %s", rvalue); return 0; } -- 2.25.1