From 1f97091d3cb0887c264176b47b0a86c269acf0b5 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 27 Jun 2014 18:34:37 +0200 Subject: [PATCH] main: uid_to_name() might fail due to OOM, protect against that --- src/core/main.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/core/main.c b/src/core/main.c index 8ee12ef8fab..38835fc6200 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -1547,9 +1547,10 @@ int main(int argc, char *argv[]) { if (empty_etc) log_info("Running with unpopulated /etc."); } else { - _cleanup_free_ char *t = uid_to_name(getuid()); - log_debug(PACKAGE_STRING " running in user mode for user "UID_FMT"/%s. (" SYSTEMD_FEATURES ")", - getuid(), t); + _cleanup_free_ char *t; + + t = uid_to_name(getuid()); + log_debug(PACKAGE_STRING " running in user mode for user "UID_FMT"/%s. (" SYSTEMD_FEATURES ")", getuid(), strna(t)); } if (arg_running_as == SYSTEMD_SYSTEM && !skip_setup) {