svn commit: r315721 - stable/11/bin/kill
Bryan Drewery
bdrewery at FreeBSD.org
Wed Mar 22 17:46:09 UTC 2017
Author: bdrewery
Date: Wed Mar 22 17:46:08 2017
New Revision: 315721
URL: https://svnweb.freebsd.org/changeset/base/315721
Log:
MFC r314714:
Don't kill pid -1 on overflow from strtol(3).
Modified:
stable/11/bin/kill/kill.c
Directory Properties:
stable/11/ (props changed)
Modified: stable/11/bin/kill/kill.c
==============================================================================
--- stable/11/bin/kill/kill.c Wed Mar 22 17:37:47 2017 (r315720)
+++ stable/11/bin/kill/kill.c Wed Mar 22 17:46:08 2017 (r315721)
@@ -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);
}
More information about the svn-src-stable
mailing list