summaryrefslogtreecommitdiff
path: root/src/sysv-generator
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-07-29 22:01:36 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-07-31 04:00:31 -0400
commita2a5291b3f5ab6ed4c92f51d0fd10a03047380d8 (patch)
tree1a74a85c70861b0a411d9dd325b039976de4fd4e /src/sysv-generator
parent73381fcf54e38456067f0e87b8611a21eff99169 (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/sysv-generator')
-rw-r--r--src/sysv-generator/sysv-generator.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/sysv-generator/sysv-generator.c b/src/sysv-generator/sysv-generator.c
index 9a869badc..cfae1d75b 100644
--- a/src/sysv-generator/sysv-generator.c
+++ b/src/sysv-generator/sysv-generator.c
@@ -442,15 +442,15 @@ static int load_sysv(SysvStub *s) {
} else if (state == LSB || state == LSB_DESCRIPTION) {
if (startswith_no_case(t, "Provides:")) {
- char *i, *w;
+ const char *word, *state_;
size_t z;
state = LSB;
- FOREACH_WORD_QUOTED(w, z, t+9, i) {
+ FOREACH_WORD_QUOTED(word, z, t+9, state_) {
_cleanup_free_ char *n = NULL, *m = NULL;
- n = strndup(w, z);
+ n = strndup(word, z);
if (!n)
return -ENOMEM;
@@ -499,16 +499,16 @@ static int load_sysv(SysvStub *s) {
startswith_no_case(t, "Should-Start:") ||
startswith_no_case(t, "X-Start-Before:") ||
startswith_no_case(t, "X-Start-After:")) {
- char *i, *w;
+ const char *word, *state_;
size_t z;
state = LSB;
- FOREACH_WORD_QUOTED(w, z, strchr(t, ':')+1, i) {
+ FOREACH_WORD_QUOTED(word, z, strchr(t, ':')+1, state_) {
_cleanup_free_ char *n = NULL, *m = NULL;
bool is_before;
- n = strndup(w, z);
+ n = strndup(word, z);
if (!n)
return -ENOMEM;