mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-02-04 17:47:03 +03:00
util: use quoted word parsing where applicable
This commit is contained in:
parent
6febfd0d4b
commit
f60f22dfbb
@ -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;
|
||||
}
|
||||
|
@ -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))) {
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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))) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user