From owner-svn-src-head@freebsd.org Sun Mar 5 21:56:05 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C3DA6CFAFEF; Sun, 5 Mar 2017 21:56:05 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 836751F86; Sun, 5 Mar 2017 21:56:05 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v25Lu43d088687; Sun, 5 Mar 2017 21:56:04 GMT (envelope-from bdrewery@FreeBSD.org) Received: (from bdrewery@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v25Lu42r088686; Sun, 5 Mar 2017 21:56:04 GMT (envelope-from bdrewery@FreeBSD.org) Message-Id: <201703052156.v25Lu42r088686@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bdrewery set sender to bdrewery@FreeBSD.org using -f From: Bryan Drewery Date: Sun, 5 Mar 2017 21:56:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r314714 - head/bin/kill X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 05 Mar 2017 21:56:05 -0000 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); }