From: Lennart Poettering Date: Thu, 16 Jun 2016 20:46:44 +0000 (+0200) Subject: process-util: fix two bugs in get_process_cmdline() (#3555) X-Git-Tag: v231~146 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b09df4e21dd191dabe382d702744df57d9d448a5;p=thirdparty%2Fsystemd.git process-util: fix two bugs in get_process_cmdline() (#3555) See: https://github.com/systemd/systemd/pull/3529#issuecomment-226421007 --- diff --git a/src/basic/process-util.c b/src/basic/process-util.c index b5b068ad389..20768b715af 100644 --- a/src/basic/process-util.c +++ b/src/basic/process-util.c @@ -161,6 +161,8 @@ int get_process_cmdline(pid_t pid, size_t max_length, bool comm_fallback, char * if (len > 0) r[len] = 0; + else + r = mfree(r); } else { bool dotdotdot = false; @@ -214,7 +216,7 @@ int get_process_cmdline(pid_t pid, size_t max_length, bool comm_fallback, char * } strncpy(k, "...", left-1); - k[left] = 0; + k[left-1] = 0; } else *k = 0; }