diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-08-14 22:33:10 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-08-14 22:33:10 +0200 |
commit | 16d1e3c26fc2908d430aa94cc76227028b0fffc7 (patch) | |
tree | c0234376bfa1f9eac49341f1f8add9c7b29b9214 /procps | |
parent | 5da42fce51a9913e2c4359b71f4184dba0ad4310 (diff) | |
download | busybox-16d1e3c26fc2908d430aa94cc76227028b0fffc7.tar.gz |
pgrep: match argv[0] too, not only comm; fix a bug in argv sanitization
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'procps')
-rw-r--r-- | procps/pgrep.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/procps/pgrep.c b/procps/pgrep.c index aef4f229a..3a717ecff 100644 --- a/procps/pgrep.c +++ b/procps/pgrep.c @@ -92,7 +92,7 @@ int pgrep_main(int argc UNUSED_PARAM, char **argv) if (sid2match == 0) sid2match = getsid(pid); - scan_mask = PSSCAN_COMM; + scan_mask = PSSCAN_COMM | PSSCAN_ARGV0; if (OPT_FULL) scan_mask |= PSSCAN_ARGVN; @@ -117,9 +117,9 @@ int pgrep_main(int argc UNUSED_PARAM, char **argv) cmd = proc->comm; } else { int i = proc->argv_len; - while (i) { - if (!cmd[i]) cmd[i] = ' '; - i--; + while (--i >= 0) { + if ((unsigned char)cmd[i] < ' ') + cmd[i] = ' '; } } |