From owner-svn-src-stable-11@freebsd.org Thu Jan 11 23:58:42 2018 Return-Path: Delivered-To: svn-src-stable-11@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 7CF57E6072F; Thu, 11 Jan 2018 23:58:42 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5708C6C254; Thu, 11 Jan 2018 23:58:42 +0000 (UTC) (envelope-from asomers@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 94C941C0B4; Thu, 11 Jan 2018 23:58:41 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w0BNwfEM003503; Thu, 11 Jan 2018 23:58:41 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w0BNwfTv003502; Thu, 11 Jan 2018 23:58:41 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201801112358.w0BNwfTv003502@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Thu, 11 Jan 2018 23:58:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327851 - stable/11/lib/libcam X-SVN-Group: stable-11 X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: stable/11/lib/libcam X-SVN-Commit-Revision: 327851 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Jan 2018 23:58:42 -0000 Author: asomers Date: Thu Jan 11 23:58:41 2018 New Revision: 327851 URL: https://svnweb.freebsd.org/changeset/base/327851 Log: MFC r326646: Fix a null-pointer dereference and a tautological check in cam_get_device Reported by: Coverity CID: 1017964 Sponsored by: Spectra Logic Corp Differential Revision: https://reviews.freebsd.org/D13184 Modified: stable/11/lib/libcam/camlib.c Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libcam/camlib.c ============================================================================== --- stable/11/lib/libcam/camlib.c Thu Jan 11 23:57:55 2018 (r327850) +++ stable/11/lib/libcam/camlib.c Thu Jan 11 23:58:41 2018 (r327851) @@ -28,6 +28,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -130,6 +131,9 @@ cam_get_device(const char *path, char *dev_name, int d * it so we don't hose the user's string. */ newpath = (char *)strdup(path); + if (newpath == NULL) + return (-1); + tmpstr = newpath; /* @@ -138,8 +142,9 @@ cam_get_device(const char *path, char *dev_name, int d if (*tmpstr == '/') { tmpstr2 = tmpstr; tmpstr = strrchr(tmpstr2, '/'); - if ((tmpstr != NULL) && (*tmpstr != '\0')) - tmpstr++; + /* We know that tmpstr2 contains a '/', so strrchr can't fail */ + assert(tmpstr != NULL && *tmpstr != '\0'); + tmpstr++; } if (*tmpstr == '\0') {