summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorbdrewery <bdrewery@FreeBSD.org>2017-03-22 17:46:08 +0000
committerbdrewery <bdrewery@FreeBSD.org>2017-03-22 17:46:08 +0000
commit9bbcb4a042df2ed01fc31c024908ca24ca9c3d9f (patch)
treee11a8bb86cb54971f12198dc4fb2563551366d4c /bin
parent4d00009daee2708ebd78ccdab44fdfe86db86f87 (diff)
downloadFreeBSD-src-9bbcb4a042df2ed01fc31c024908ca24ca9c3d9f.zip
FreeBSD-src-9bbcb4a042df2ed01fc31c024908ca24ca9c3d9f.tar.gz
MFC r314714:
Don't kill pid -1 on overflow from strtol(3).
Diffstat (limited to 'bin')
-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 bfa274b..c0ee194 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);
}
OpenPOWER on IntegriCloud