diff options
author | Lennart Poettering <lennart@poettering.net> | 2016-06-16 22:46:44 +0200 |
---|---|---|
committer | Sven Eden <yamakuzure@gmx.net> | 2017-06-16 10:13:01 +0200 |
commit | f1589a158ed3fdcd1ec6b2a58f35d743bdd08cd5 (patch) | |
tree | cf921f05add67435f38132830edf20972bb94572 /src/basic/process-util.c | |
parent | 08b0b97aed0c478215d563b9e29b5333e19aef45 (diff) |
process-util: fix two bugs in get_process_cmdline() (#3555)
See:
https://github.com/elogind/elogind/pull/3529#issuecomment-226421007
Diffstat (limited to 'src/basic/process-util.c')
-rw-r--r-- | src/basic/process-util.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/basic/process-util.c b/src/basic/process-util.c index dd77df2ab..5bf0a180b 100644 --- a/src/basic/process-util.c +++ b/src/basic/process-util.c @@ -160,6 +160,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; @@ -213,7 +215,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; } |