diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2014-07-29 22:01:36 -0400 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2014-07-31 04:00:31 -0400 |
commit | a2a5291b3f5ab6ed4c92f51d0fd10a03047380d8 (patch) | |
tree | 1a74a85c70861b0a411d9dd325b039976de4fd4e /src/timesync/timesyncd.c | |
parent | 73381fcf54e38456067f0e87b8611a21eff99169 (diff) |
Reject invalid quoted strings
String which ended in an unfinished quote were accepted, potentially
with bad memory accesses.
Reject anything which ends in a unfished quote, or contains
non-whitespace characters right after the closing quote.
_FOREACH_WORD now returns the invalid character in *state. But this return
value is not checked anywhere yet.
Also, make 'word' and 'state' variables const pointers, and rename 'w'
to 'word' in various places. Things are easier to read if the same name
is used consistently.
mbiebl_> am I correct that something like this doesn't work
mbiebl_> ExecStart=/usr/bin/encfs --extpass='/bin/systemd-ask-passwd "Unlock EncFS"'
mbiebl_> systemd seems to strip of the quotes
mbiebl_> systemctl status shows
mbiebl_> ExecStart=/usr/bin/encfs --extpass='/bin/systemd-ask-password Unlock EncFS $RootDir $MountPoint
mbiebl_> which is pretty weird
Diffstat (limited to 'src/timesync/timesyncd.c')
-rw-r--r-- | src/timesync/timesyncd.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/timesync/timesyncd.c b/src/timesync/timesyncd.c index b80e03b349..8bb79fb5ee 100644 --- a/src/timesync/timesyncd.c +++ b/src/timesync/timesyncd.c @@ -984,17 +984,17 @@ static int manager_add_server(Manager *m, const char *server) { } static int manager_add_server_string(Manager *m, const char *string) { - char *w, *state; + const char *word, *state; size_t l; int r; assert(m); assert(string); - FOREACH_WORD_QUOTED(w, l, string, state) { + FOREACH_WORD_QUOTED(word, l, string, state) { char t[l+1]; - memcpy(t, w, l); + memcpy(t, word, l); t[l] = 0; r = manager_add_server(m, t); |