diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2014-07-30 04:01:36 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2014-07-31 10:00:31 +0200 |
commit | a2a5291b3f5ab6ed4c92f51d0fd10a03047380d8 (patch) | |
tree | 1a74a85c70861b0a411d9dd325b039976de4fd4e /src/getty-generator | |
parent | test-strv: add test which shows access to random memory (diff) | |
download | systemd-a2a5291b3f5ab6ed4c92f51d0fd10a03047380d8.tar.xz systemd-a2a5291b3f5ab6ed4c92f51d0fd10a03047380d8.zip |
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/getty-generator')
-rw-r--r-- | src/getty-generator/getty-generator.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/getty-generator/getty-generator.c b/src/getty-generator/getty-generator.c index 7d4b546f72..c78a511f94 100644 --- a/src/getty-generator/getty-generator.c +++ b/src/getty-generator/getty-generator.c @@ -154,14 +154,14 @@ int main(int argc, char *argv[]) { r = getenv_for_pid(1, "container_ttys", &container_ttys); if (r > 0) { - char *w, *state; + const char *word, *state; size_t l; - FOREACH_WORD(w, l, container_ttys, state) { + FOREACH_WORD(word, l, container_ttys, state) { const char *t; char tty[l + 1]; - memcpy(tty, w, l); + memcpy(tty, word, l); tty[l] = 0; /* First strip off /dev/ if it is specified */ @@ -184,15 +184,15 @@ int main(int argc, char *argv[]) { } if (read_one_line_file("/sys/class/tty/console/active", &active) >= 0) { - char *w, *state; + const char *word, *state; size_t l; /* Automatically add in a serial getty on all active * kernel consoles */ - FOREACH_WORD(w, l, active, state) { + FOREACH_WORD(word, l, active, state) { _cleanup_free_ char *tty = NULL; - tty = strndup(w, l); + tty = strndup(word, l); if (!tty) { log_oom(); return EXIT_FAILURE; |