[systemd-devel] [PATCH] util: don't consider trailing whitespaces as an empty string in split_quoted

Lennart Poettering lennart at poettering.net
Wed Nov 27 13:43:17 PST 2013


On Wed, 27.11.13 18:00, Lukas Nykryn (lnykryn at redhat.com) wrote:

I merged a different patch that simply moves the earlier NUL byte check
after the jumping over whitespace, so that we don't need two checks. I
also added a test case for this, so that this doesn't break again.

(That sad, the whole function is moronic, since it doesn't really do any
sane unescaping of quotes inside of strings... We should rewrite this
one day, and maybe do it in a smart way that allocates a dynamically
sized string of the current word on the stack...)

> ---
>  src/shared/util.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/src/shared/util.c b/src/shared/util.c
> index 3a4d196..c68ab09 100644
> --- a/src/shared/util.c
> +++ b/src/shared/util.c
> @@ -383,7 +383,9 @@ char *split_quoted(const char *c, size_t *l, char **state) {
>  
>          current += strspn(current, WHITESPACE);
>  
> -        if (*current == '\'') {
> +        if (*current == 0)
> +                return NULL;
> +        else if (*current == '\'') {
>                  current ++;
>  
>                  for (e = current; *e; e++) {


Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list