From f60f22dfbb8cfa0eb55d1896db0e4c3f7d3cfacb Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 7 Jul 2010 20:58:41 +0200 Subject: [PATCH] util: use quoted word parsing where applicable --- src/conf-parser.c | 4 ++-- src/device.c | 2 +- src/load-fragment.c | 16 ++++++++-------- src/main.c | 2 +- src/service.c | 4 ++-- src/strv.c | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/conf-parser.c b/src/conf-parser.c index df3584dd0..1cabc0d78 100644 --- a/src/conf-parser.c +++ b/src/conf-parser.c @@ -423,7 +423,7 @@ int config_parse_strv( k = 0; FOREACH_WORD_QUOTED(w, l, rvalue, state) - if (!(n[k++] = strndup(w, l))) + if (!(n[k++] = cunescape_length(w, l))) goto fail; n[k] = NULL; @@ -475,7 +475,7 @@ int config_parse_path_strv( n[k] = (*sv)[k]; FOREACH_WORD_QUOTED(w, l, rvalue, state) { - if (!(n[k] = strndup(w, l))) { + if (!(n[k] = cunescape_length(w, l))) { r = -ENOMEM; goto fail; } diff --git a/src/device.c b/src/device.c index a0349c430..2079f1c4e 100644 --- a/src/device.c +++ b/src/device.c @@ -244,7 +244,7 @@ static int device_process_new_device(Manager *m, struct udev_device *dev, bool u goto fail; if (wants) { - FOREACH_WORD(w, l, wants, state) { + FOREACH_WORD_QUOTED(w, l, wants, state) { char *e; if (!(e = strndup(w, l))) { diff --git a/src/load-fragment.c b/src/load-fragment.c index 1cc7c5cc3..43b8093fa 100644 --- a/src/load-fragment.c +++ b/src/load-fragment.c @@ -61,7 +61,7 @@ static int config_parse_deps( assert(lvalue); assert(rvalue); - FOREACH_WORD(w, l, rvalue, state) { + FOREACH_WORD_QUOTED(w, l, rvalue, state) { char *t, *k; int r; @@ -103,7 +103,7 @@ static int config_parse_names( assert(rvalue); assert(data); - FOREACH_WORD(w, l, rvalue, state) { + FOREACH_WORD_QUOTED(w, l, rvalue, state) { char *t, *k; int r; @@ -689,7 +689,7 @@ static int config_parse_cpu_affinity( assert(rvalue); assert(data); - FOREACH_WORD(w, l, rvalue, state) { + FOREACH_WORD_QUOTED(w, l, rvalue, state) { char *t; int r; unsigned cpu; @@ -766,7 +766,7 @@ static int config_parse_secure_bits( assert(rvalue); assert(data); - FOREACH_WORD(w, l, rvalue, state) { + FOREACH_WORD_QUOTED(w, l, rvalue, state) { if (first_word(w, "keep-caps")) c->secure_bits |= SECURE_KEEP_CAPS; else if (first_word(w, "keep-caps-locked")) @@ -807,7 +807,7 @@ static int config_parse_bounding_set( assert(rvalue); assert(data); - FOREACH_WORD(w, l, rvalue, state) { + FOREACH_WORD_QUOTED(w, l, rvalue, state) { char *t; int r; cap_value_t cap; @@ -902,11 +902,11 @@ static int config_parse_cgroup( size_t l; char *state; - FOREACH_WORD(w, l, rvalue, state) { + FOREACH_WORD_QUOTED(w, l, rvalue, state) { char *t; int r; - if (!(t = strndup(w, l))) + if (!(t = cunescape_length(w, l))) return -ENOMEM; r = unit_add_cgroup_from_text(u, t); @@ -967,7 +967,7 @@ static int config_parse_mount_flags( assert(rvalue); assert(data); - FOREACH_WORD(w, l, rvalue, state) { + FOREACH_WORD_QUOTED(w, l, rvalue, state) { if (strncmp(w, "shared", l) == 0) flags |= MS_SHARED; else if (strncmp(w, "slave", l) == 0) diff --git a/src/main.c b/src/main.c index 592edbe76..d5902b354 100644 --- a/src/main.c +++ b/src/main.c @@ -426,7 +426,7 @@ static int config_parse_cpu_affinity( assert(lvalue); assert(rvalue); - FOREACH_WORD(w, l, rvalue, state) { + FOREACH_WORD_QUOTED(w, l, rvalue, state) { char *t; int r; unsigned cpu; diff --git a/src/service.c b/src/service.c index ccc83128b..fed822729 100644 --- a/src/service.c +++ b/src/service.c @@ -526,7 +526,7 @@ static int service_load_sysv_path(Service *s, const char *path) { state = LSB; - FOREACH_WORD(w, z, t+9, i) { + FOREACH_WORD_QUOTED(w, z, t+9, i) { char *n, *m; if (!(n = strndup(w, z))) { @@ -563,7 +563,7 @@ static int service_load_sysv_path(Service *s, const char *path) { state = LSB; - FOREACH_WORD(w, z, strchr(t, ':')+1, i) { + FOREACH_WORD_QUOTED(w, z, strchr(t, ':')+1, i) { char *n, *m; if (!(n = strndup(w, z))) { diff --git a/src/strv.c b/src/strv.c index 01464e1e3..a66369602 100644 --- a/src/strv.c +++ b/src/strv.c @@ -264,7 +264,7 @@ char **strv_split_quoted(const char *s) { i = 0; FOREACH_WORD_QUOTED(w, l, s, state) - if (!(r[i++] = strndup(w, l))) { + if (!(r[i++] = cunescape_length(w, l))) { strv_free(r); return NULL; } -- 2.30.2