summaryrefslogtreecommitdiffstats
path: root/src/basic
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@codethink.co.uk>2015-07-24 11:29:46 +0200
committerRichard Maw <richard.maw@codethink.co.uk>2015-07-24 11:29:46 +0200
commit14e685c29d5b317b815e3e9f056648027852b07e (patch)
treebe251d64d02f91ebafddaf5f3c868399b17b3970 /src/basic
parentbuild: add convenience target 'build-sources' (diff)
downloadsystemd-14e685c29d5b317b815e3e9f056648027852b07e.tar.xz
systemd-14e685c29d5b317b815e3e9f056648027852b07e.zip
unquote_first_word: parse ` '' ` as an empty argument instead of no argument
Diffstat (limited to 'src/basic')
-rw-r--r--src/basic/util.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/basic/util.c b/src/basic/util.c
index a45f5f8e53..7d85324d07 100644
--- a/src/basic/util.c
+++ b/src/basic/util.c
@@ -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))