]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/basic/util.c
unquote_first_word: parse ` '' ` as an empty argument instead of no argument
[thirdparty/systemd.git] / src / basic / util.c
index a45f5f8e53055c20213f5fcba160b07945820ae9..7d85324d0786021ec158a431318c2476401b1a9e 100644 (file)
@@ -5379,13 +5379,19 @@ int unquote_first_word(const char **p, char **ret, UnquoteFlags flags) {
                 case VALUE:
                         if (c == 0)
                                 goto finish;
-                        else if (c == '\'')
+                        else if (c == '\'') {
+                                if (!GREEDY_REALLOC(s, allocated, sz+1))
+                                        return -ENOMEM;
+
                                 state = SINGLE_QUOTE;
-                        else if (c == '\\')
+                        else if (c == '\\')
                                 state = VALUE_ESCAPE;
-                        else if (c == '\"')
+                        else if (c == '\"') {
+                                if (!GREEDY_REALLOC(s, allocated, sz+1))
+                                        return -ENOMEM;
+
                                 state = DOUBLE_QUOTE;
-                        else if (strchr(WHITESPACE, c))
+                        else if (strchr(WHITESPACE, c))
                                 state = SPACE;
                         else {
                                 if (!GREEDY_REALLOC(s, allocated, sz+2))