]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
process-util: fix two bugs in get_process_cmdline() (#3555)
authorLennart Poettering <lennart@poettering.net>
Thu, 16 Jun 2016 20:46:44 +0000 (22:46 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 16 Jun 2016 20:46:44 +0000 (16:46 -0400)
See:

https://github.com/systemd/systemd/pull/3529#issuecomment-226421007

src/basic/process-util.c

index b5b068ad389d26e65d781b095431725c7b4a1c74..20768b715af228de4b22721190c1363ba992c68a 100644 (file)
@@ -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;
         }