Date: Sun, 5 Mar 2017 21:56:04 +0000 (UTC) From: Bryan Drewery <bdrewery@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r314714 - head/bin/kill Message-ID: <201703052156.v25Lu42r088686@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: bdrewery Date: Sun Mar 5 21:56:04 2017 New Revision: 314714 URL: https://svnweb.freebsd.org/changeset/base/314714 Log: Don't kill pid -1 on overflow from strtol(3). Store the result in a proper long and then compare to the proper pid_t for overflow, so that no MD assumptions are made. Reviewed by: jilles MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D9887 Modified: head/bin/kill/kill.c Modified: head/bin/kill/kill.c ============================================================================== --- head/bin/kill/kill.c Sun Mar 5 21:44:29 2017 (r314713) +++ head/bin/kill/kill.c Sun Mar 5 21:56:04 2017 (r314714) @@ -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?201703052156.v25Lu42r088686>