From b2fadec6048adb3596f2633cb7fe7a49f5937a18 Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Thu, 31 Jul 2014 03:28:37 -0400 Subject: Properly report invalid quoted strings $ systemd-analyze verify trailing-g.service [./trailing-g.service:2] Trailing garbage, ignoring. trailing-g.service lacks ExecStart setting. Refusing. Error: org.freedesktop.systemd1.LoadFailed: Unit trailing-g.service failed to load: Invalid argument. Failed to create trailing-g.service/start: Invalid argument --- src/locale/localed.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/locale/localed.c') diff --git a/src/locale/localed.c b/src/locale/localed.c index d6ffe67520..bce99b8cba 100644 --- a/src/locale/localed.c +++ b/src/locale/localed.c @@ -210,6 +210,7 @@ static int x11_read_data(Context *c) { FILE *f; char line[LINE_MAX]; bool in_section = false; + int r; context_free_x11(c); @@ -229,10 +230,10 @@ static int x11_read_data(Context *c) { if (in_section && first_word(l, "Option")) { char **a; - a = strv_split_quoted(l); - if (!a) { + r = strv_split_quoted(&a, l); + if (r < 0) { fclose(f); - return -ENOMEM; + return r; } if (strv_length(a) == 3) { @@ -256,8 +257,8 @@ static int x11_read_data(Context *c) { } else if (!in_section && first_word(l, "Section")) { char **a; - a = strv_split_quoted(l); - if (!a) { + r = strv_split_quoted(&a, l); + if (r < 0) { fclose(f); return -ENOMEM; } @@ -533,6 +534,7 @@ static int read_next_mapping(FILE *f, unsigned *n, char ***a) { for (;;) { char line[LINE_MAX]; char *l, **b; + int r; errno = 0; if (!fgets(line, sizeof(line), f)) { @@ -549,9 +551,9 @@ static int read_next_mapping(FILE *f, unsigned *n, char ***a) { if (l[0] == 0 || l[0] == '#') continue; - b = strv_split_quoted(l); - if (!b) - return -ENOMEM; + r = strv_split_quoted(&b, l); + if (r < 0) + return r; if (strv_length(b) < 5) { log_error("Invalid line "SYSTEMD_KBD_MODEL_MAP":%u, ignoring.", *n); -- cgit v1.2.3-54-g00ecf