Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 22 Mar 2017 17:49:56 +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-10@freebsd.org
Subject:   svn commit: r315722 - stable/10/bin/kill
Message-ID:  <201703221749.v2MHnuoM028127@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: bdrewery
Date: Wed Mar 22 17:49:56 2017
New Revision: 315722
URL: https://svnweb.freebsd.org/changeset/base/315722

Log:
  MFC r314714:
  
    Don't kill pid -1 on overflow from strtol(3).

Modified:
  stable/10/bin/kill/kill.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/bin/kill/kill.c
==============================================================================
--- stable/10/bin/kill/kill.c	Wed Mar 22 17:46:08 2017	(r315721)
+++ stable/10/bin/kill/kill.c	Wed Mar 22 17:49:56 2017	(r315722)
@@ -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) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201703221749.v2MHnuoM028127>