Date: Wed, 22 Mar 2017 17:46:08 +0000 (UTC) From: Bryan Drewery <bdrewery@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315721 - stable/11/bin/kill Message-ID: <201703221746.v2MHk8f2027951@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201703221746.v2MHk8f2027951>