psmisc/backport-0008-pstree-consecutive-NULs-in-cmdline-args-wrongly-pars.patch
2020-11-03 16:08:43 +08:00

32 lines
966 B
Diff

From c028ba11f90beecbd48d9a9f9ae8151622ea5fbc Mon Sep 17 00:00:00 2001
From: Jan Rybar <jrybar@redhat.com>
Date: Wed, 29 Apr 2020 17:26:51 +0200
Subject: [PATCH 16/20] pstree: consecutive NULs in cmdline args wrongly parsed
https://gitlab.com/psmisc/psmisc/-/commit/c028ba11f90beecbd48d9a9f9ae8151622ea5fbc
---
src/pstree.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/pstree.c b/src/pstree.c
index da02564..44e932c 100644
--- a/src/pstree.c
+++ b/src/pstree.c
@@ -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))) {
--
2.22.0.windows.1