diff options
author | bdrewery <bdrewery@FreeBSD.org> | 2017-03-22 17:49:56 +0000 |
---|---|---|
committer | bdrewery <bdrewery@FreeBSD.org> | 2017-03-22 17:49:56 +0000 |
commit | 917c6988a2b34ad49e5ee3d4395e0a22323c56cd (patch) | |
tree | 36fb90318dc8c8a7a7236cb09c6639ac10a86509 /bin | |
parent | b4318853804f0cf78d2c759bb606d5438fcb02fd (diff) | |
download | FreeBSD-src-917c6988a2b34ad49e5ee3d4395e0a22323c56cd.zip FreeBSD-src-917c6988a2b34ad49e5ee3d4395e0a22323c56cd.tar.gz |
MFC r314714:
Don't kill pid -1 on overflow from strtol(3).
Diffstat (limited to 'bin')
-rw-r--r-- | bin/kill/kill.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/bin/kill/kill.c b/bin/kill/kill.c index 2d41f78..df5b70d 100644 --- a/bin/kill/kill.c +++ b/bin/kill/kill.c @@ -67,7 +67,9 @@ static void usage(void); int main(int argc, char *argv[]) { - int errors, numsig, pid; + long pidl; + pid_t pid; + int errors, numsig; char *ep; if (argc < 2) @@ -138,8 +140,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); } if (kill(pid, numsig) == -1) { |