From d233c99ac8125daa04e87f67cf13ee01fe3d9a1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Fri, 23 Jun 2017 19:20:54 -0400 Subject: [PATCH] manager: just warn about an invalid environment entry Apart from bugs (as in #6152), this can happen if we ever make our requirements for environment entries more stringent. As with the rest of deserialization, we should just warn and continue. --- src/basic/env-util.c | 2 +- src/core/manager.c | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/basic/env-util.c b/src/basic/env-util.c index e79b441ab6..c2a6f6f56e 100644 --- a/src/basic/env-util.c +++ b/src/basic/env-util.c @@ -788,7 +788,7 @@ int serialize_environment(FILE *f, char **environment) { } int deserialize_environment(char ***environment, const char *line) { - char *uce = NULL; + char *uce; int r; assert(line); diff --git a/src/core/manager.c b/src/core/manager.c index 876210f353..283720750f 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -2588,8 +2588,8 @@ int manager_deserialize(Manager *m, FILE *f, FDSet *fds) { m->n_reloading++; for (;;) { - char line[LINE_MAX], *l; - const char *val; + char line[LINE_MAX]; + const char *val, *l; if (!fgets(line, sizeof(line), f)) { if (feof(f)) @@ -2665,8 +2665,10 @@ int manager_deserialize(Manager *m, FILE *f, FDSet *fds) { dual_timestamp_deserialize(val, &m->units_load_finish_timestamp); else if (startswith(l, "env=")) { r = deserialize_environment(&m->environment, l); + if (r == -ENOMEM) + goto finish; if (r < 0) - return r; + log_notice_errno(r, "Failed to parse environment entry: \"%s\": %m", l); } else if ((val = startswith(l, "notify-fd="))) { int fd;