]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsfd: (filter): parse "" in filter expression correctly
authorMasatake YAMATO <yamato@redhat.com>
Mon, 4 Apr 2022 18:58:59 +0000 (03:58 +0900)
committerMasatake YAMATO <yamato@redhat.com>
Mon, 4 Apr 2022 19:39:24 +0000 (04:39 +0900)
The original code cannot convert "" in filter expression to
a token correctly. The following command line exposes the
bug this change fixes:

  # ./lsfd  -o+ENDPOINTS  -Q '(TYPE == "")'
  zsh: IOT instruction  sudo ./lsfd -Q '(TYPE == "")'

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
misc-utils/lsfd-filter.c

index b70da18d0b0d498dfae84ce72db08f9bf1cbabd4..844adb0a2cab32520b3f7345583cd798318c6f11 100644 (file)
@@ -438,9 +438,11 @@ static void parser_read_str(struct parser *parser, struct token *token, char del
                                return;
                        }
                        escape = false;
-               } else if (c == delimiter)
+               } else if (c == delimiter) {
+                       if (token->val.str == NULL)
+                               token->val.str = xstrdup("");
                        return;
-               else if (c == '\\')
+               else if (c == '\\')
                        escape = true;
                else
                        xstrputc(&token->val.str, c);