[systemd-devel] [PATCH] core: Fix assertion with empty Exec*= paths

Zbigniew Jędrzejewski-Szmek zbyszek at in.waw.pl
Thu May 14 05:28:08 PDT 2015


On Thu, May 14, 2015 at 09:15:10AM +0200, Martin Pitt wrote:
> From 10f6ac7c8b3dad0197ce795e33383c24ea2d53b1 Mon Sep 17 00:00:00 2001
> From: Martin Pitt <martin.pitt at ubuntu.com>
> Date: Thu, 14 May 2015 09:06:40 +0200
> Subject: [PATCH] core: Fix assertion with empty Exec*= paths
> 
> An Exec*= line with whitespace after modifiers, like
> 
>   ExecStart=- /bin/true
> 
> is considered to have an empty command path. This is as specified, but causes
> systemd to crash with
> 
>   Assertion 'skip < l' failed at ../src/core/load-fragment.c:607, function config_parse_exec(). Aborting.
>   Aborted (core dumped)
> 
> Fix this by logging an error instead and ignoring the invalid line.
> 
> Add corresponding test cases. Also add a test case for a completely empty value
> which resets the command list.
> 
> https://launchpad.net/bugs/1454173
> ---
>  src/core/load-fragment.c  |  6 +++++-
>  src/test/test-unit-file.c | 21 +++++++++++++++++++++
>  2 files changed, 26 insertions(+), 1 deletion(-)
> 
> diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
> index 33d9e27..3865017 100644
> --- a/src/core/load-fragment.c
> +++ b/src/core/load-fragment.c
> @@ -595,7 +595,11 @@ int config_parse_exec(
>                                  skip = separate_argv0 + ignore;
>  
>                                  /* skip special chars in the beginning */
> -                                assert(skip < l);
> +                                if (l <= skip) {
> +                                        log_syntax(unit, LOG_ERR, filename, line, EINVAL, "Empty path in command line, ignoring: %s", rvalue);
> +                                        r = 0;
> +                                        goto fail;
> +                                }
>  
>                          } else if (strneq(word, ";", MAX(l, 1U)))
>                                  /* new commandline */
Looks OK, but it'd be nice to add quotes because of spaces: ...\"%s\"...

Zbyszek


More information about the systemd-devel mailing list