]> granicus.if.org Git - psmisc/commitdiff
pstree: consecutive NULs in cmdline args wrongly parsed
authorJan Rybar <jrybar@redhat.com>
Wed, 29 Apr 2020 15:26:51 +0000 (17:26 +0200)
committerCraig Small <csmall@dropbear.xyz>
Tue, 5 May 2020 03:50:02 +0000 (13:50 +1000)
src/pstree.c

index da02564a0774195582924d276879ad097a226d3e..44e932c8c62f9688d59386731f12ced4cad2fe1e 100644 (file)
@@ -571,8 +571,12 @@ static void set_args(PROC * this, const char *args, int size)
     }
     this->argc = 0;
     for (i = 0; i < size - 1; i++)
-        if (!args[i])
+        if (!args[i]) {
             this->argc++;
+            /* now skip consecutive NUL */
+            while(!args[i] && (i < size -1 ))
+                i++;
+        }
     if (!this->argc)
         return;
     if (!(this->argv = malloc(sizeof(char *) * this->argc))) {