summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-06-16 22:46:44 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-06-16 16:46:44 -0400
commitb09df4e21dd191dabe382d702744df57d9d448a5 (patch)
treecf281941a2861a1280a0d47524070e9b37b8c793
parent749a1d0684f5ecce6cf6ee8ceb44975e90fec7e9 (diff)
process-util: fix two bugs in get_process_cmdline() (#3555)
See: https://github.com/systemd/systemd/pull/3529#issuecomment-226421007
-rw-r--r--src/basic/process-util.c4
1 files changed, 3 insertions, 1 deletions
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;
}