summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan Drewery <bdrewery@FreeBSD.org>2017-03-05 21:56:04 +0000
committerBryan Drewery <bdrewery@FreeBSD.org>2017-03-05 21:56:04 +0000
commit27ca6260e0f2f83d19d1b37161afec96b6949416 (patch)
tree04af2091b3d5231eb607b8cfcb9f02ad6eb49966
parent51c6e78d91a72540ae59332710d3505e99da6aef (diff)
downloadsrc-test-27ca6260e0f2f83d19d1b37161afec96b6949416.tar.gz
src-test-27ca6260e0f2f83d19d1b37161afec96b6949416.zip
Notes
-rw-r--r--bin/kill/kill.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/bin/kill/kill.c b/bin/kill/kill.c
index 4e528cca57599..095244638c65e 100644
--- a/bin/kill/kill.c
+++ b/bin/kill/kill.c
@@ -66,7 +66,9 @@ static void usage(void);
int
main(int argc, char *argv[])
{
- int errors, numsig, pid, ret;
+ long pidl;
+ pid_t pid;
+ int errors, numsig, ret;
char *ep;
if (argc < 2)
@@ -137,8 +139,10 @@ main(int argc, char *argv[])
else
#endif
{
- pid = strtol(*argv, &ep, 10);
- if (!**argv || *ep)
+ pidl = strtol(*argv, &ep, 10);
+ /* Check for overflow of pid_t. */
+ pid = (pid_t)pidl;
+ if (!**argv || *ep || pid != pidl)
errx(2, "illegal process id: %s", *argv);
ret = kill(pid, numsig);
}