]> granicus.if.org Git - procps-ng/commitdiff
pgrep: prevent buffer overflow in opts
authorFilipe Brandenburger <filbranden@google.com>
Mon, 11 May 2015 18:40:50 +0000 (11:40 -0700)
committerCraig Small <csmall@enc.com.au>
Wed, 13 May 2015 12:04:58 +0000 (22:04 +1000)
Recent commit 9742c74e7c522 ("pgrep: Enable case-insensitive process matching")
caused the "opts" string to overflow the show 32-character space allocated for
it.

Bump it up to 64 bytes, which should be enough even if more options are added.

Tested: Running ./pgrep stopped crashing and `make check` passed.

Signed-off-by: Filipe Brandenburger <filbranden@google.com>
pgrep.c

diff --git a/pgrep.c b/pgrep.c
index 27b7e89345dfb5f606107f361bf898769578e6d9..bd25eaa033c601be05517d7fb96b321f7a9389d1 100644 (file)
--- a/pgrep.c
+++ b/pgrep.c
@@ -677,7 +677,7 @@ static int signal_option(int *argc, char **argv)
 
 static void parse_opts (int argc, char **argv)
 {
-       char opts[32] = "";
+       char opts[64] = "";
        int opt;
        int criteria_count = 0;