]> granicus.if.org Git - procps-ng/commit
pkill: reject -signal number with trailing garbage
authorFilipe Brandenburger <filbranden@google.com>
Fri, 5 Jun 2015 05:33:02 +0000 (22:33 -0700)
committerCraig Small <csmall@enc.com.au>
Wed, 14 Oct 2015 10:24:38 +0000 (21:24 +1100)
commita3975a9c6098218decf2d79b01c7a70512eded9e
tree351392b797d052be4738053647606820b74ce620
parent41e7510333e8c4308668ec10d7726ba517a153ee
pkill: reject -signal number with trailing garbage

This commit prevents pkill from accepting something like `-1garbage` as
a SIGHUP. The previous code was using atoi() which does not check for
trailing garbage and would parse the above as 1.

Handling numeric signals in signal_option() is not really necessary,
since signal_name_to_number() will recognize numeric signals and parse
them properly using strtol() and checking for trailing garbage. It also
checks that the numeric signals are in the proper range. So all we need
to do is remove the buggy numeric signal handling here.

Tested with `pkill -1garbage sleep`, after this patch it will complain
that "1" is not a valid option, which is the expected.

Signed-off-by: Filipe Brandenburger <filbranden@google.com>
Ported-by: Jim Warner <james.warner@comcast.net>
From original:
commit 9646f7cba47e078855d1fc5e3be9fb05b1b89629
pgrep.c