From: Lennart Poettering Date: Wed, 16 Mar 2011 01:55:55 +0000 (+0100) Subject: main: check if we have a valid PID before getting the name of it X-Git-Tag: v21~73 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dfa7f7e139e465c7685fd530d61a52c41184bcde;p=systemd main: check if we have a valid PID before getting the name of it --- diff --git a/src/kmsg-syslogd.c b/src/kmsg-syslogd.c index 4edb1613..c78011fe 100644 --- a/src/kmsg-syslogd.c +++ b/src/kmsg-syslogd.c @@ -354,7 +354,9 @@ static int write_message(Server *s, const char *buf, struct ucred *ucred) { /* Then, add process if set */ if (read_process(&buf, &iovec[i]) > 0) i++; - else if (ucred && get_process_name(ucred->pid, &process) >= 0) + else if (ucred && + ucred->pid > 0 && + get_process_name(ucred->pid, &process) >= 0) IOVEC_SET_STRING(iovec[i++], process); /* Skip the stored PID if we have a better one */ diff --git a/src/manager.c b/src/manager.c index df75eca8..9edb8f09 100644 --- a/src/manager.c +++ b/src/manager.c @@ -2070,7 +2070,9 @@ static int manager_process_signal_fd(Manager *m) { return -errno; } - get_process_name(sfsi.ssi_pid, &p); + if (sfsi.ssi_pid > 0) + get_process_name(sfsi.ssi_pid, &p); + log_debug("Received SIG%s from PID %lu (%s)", strna(signal_to_string(sfsi.ssi_signo)), (unsigned long) sfsi.ssi_pid, strna(p));