From b09df4e21dd191dabe382d702744df57d9d448a5 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 16 Jun 2016 22:46:44 +0200 Subject: process-util: fix two bugs in get_process_cmdline() (#3555) See: https://github.com/systemd/systemd/pull/3529#issuecomment-226421007 --- src/basic/process-util.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/basic/process-util.c b/src/basic/process-util.c index b5b068ad38..20768b715a 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; } -- cgit v1.2.3-54-g00ecf