]> granicus.if.org Git - procps-ng/commitdiff
pgrep: Don't segfault with no match _______ (catch up)
authorJim Warner <james.warner@comcast.net>
Wed, 11 Apr 2018 05:00:00 +0000 (00:00 -0500)
committerCraig Small <csmall@enc.com.au>
Sat, 5 May 2018 21:19:38 +0000 (07:19 +1000)
--------------- Original Master Branch Commit Message:
If pgrep is run with a non-program name match and there are
no matches, it segfaults.

The testsuite thinks zero bytes sent, and zero bytes sent
because the program crashed is the same :/

References:
 commit 1aacf4af7f199d77fc9386e249eee654f59880db
 https://bugs.debian.org/894917

Signed-off-by: Jim Warner <james.warner@comcast.net>
NEWS
pgrep.c

diff --git a/NEWS b/NEWS
index 41032e37efaf67bcf8c6d112e0216e5dea3283a9..681d9d04e3659d0a553c3fa6fcd5d2b4f2565d71 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,7 @@
+procps-ng-3.3.14
+----------------
+  * pgrep: Don't segfault on non match                     Debian #894917
+
 procps-ng-3.3.13
 ----------------
   * library: Increment to 7:0:1
diff --git a/pgrep.c b/pgrep.c
index 051457efd1d14563f7319ebf0774be1e8d98ba2e..004b6243ef6949a99624ad004d60f92768908f66 100644 (file)
--- a/pgrep.c
+++ b/pgrep.c
@@ -592,7 +592,7 @@ static struct el * select_procs (int *num)
 
     *num = matches;
 
-    if ((!opt_full) && (strlen(opt_pattern) > 15))
+    if ((!matches) && (!opt_full) && opt_pattern && (strlen(opt_pattern) > 15))
         xwarnx(_("pattern that searches for process name longer than 15 characters will result in zero matches\n"
                  "Try `%s -f' option to match against the complete command line."),
                program_invocation_short_name);