diff options
author | Lennart Poettering <lennart@poettering.net> | 2011-01-06 23:52:58 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2011-01-07 00:49:35 +0100 |
commit | e83c7c0ba480c6d37d6d586b9337b1ad32ee52ca (patch) | |
tree | 3db22674fcbcea01f8b4bbd76603ef32d7e0750b | |
parent | 86a3475bc5087da2a28015247ff18672905044f4 (diff) |
service: don't hit an assert if information in LSB headers is incorrectly formatted
https://bugzilla.redhat.com/show_bug.cgi?id=667665
-rw-r--r-- | src/service.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/service.c b/src/service.c index 9f2ee4192f..a28eb8a6b9 100644 --- a/src/service.c +++ b/src/service.c @@ -328,10 +328,13 @@ static int sysv_translate_facility(const char *name, const char *filename, char /* If we don't know this name, fallback heuristics to figure * out whether something is a target or a service alias. */ - if (*name == '$') + if (*name == '$') { + if (!unit_prefix_is_valid(n)) + return -EINVAL; + /* Facilities starting with $ are most likely targets */ r = unit_name_build(n, NULL, ".target"); - else if (filename && streq(name, filename)) + } else if (filename && streq(name, filename)) /* Names equalling the file name of the services are redundant */ return 0; else @@ -684,10 +687,14 @@ static int service_load_sysv_path(Service *s, const char *path) { } r = sysv_translate_facility(n, file_name_from_path(path), &m); - free(n); - if (r < 0) - goto finish; + if (r < 0) { + log_error("[%s:%u] Failed to translate LSB dependency %s, ignoring: %s", path, line, n, strerror(-r)); + free(n); + continue; + } + + free(n); if (r == 0) continue; |