From owner-svn-src-all@freebsd.org Thu Mar 22 22:13:47 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1A120F4D583; Thu, 22 Mar 2018 22:13:47 +0000 (UTC) (envelope-from landonf@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 B97626E7A8; Thu, 22 Mar 2018 22:13:46 +0000 (UTC) (envelope-from landonf@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 B19A11726B; Thu, 22 Mar 2018 22:13:46 +0000 (UTC) (envelope-from landonf@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w2MMDk9w048459; Thu, 22 Mar 2018 22:13:46 GMT (envelope-from landonf@FreeBSD.org) Received: (from landonf@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w2MMDk07048458; Thu, 22 Mar 2018 22:13:46 GMT (envelope-from landonf@FreeBSD.org) Message-Id: <201803222213.w2MMDk07048458@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: landonf set sender to landonf@FreeBSD.org using -f From: "Landon J. Fuller" Date: Thu, 22 Mar 2018 22:13:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331378 - head/sys/dev/bhnd/nvram X-SVN-Group: head X-SVN-Commit-Author: landonf X-SVN-Commit-Paths: head/sys/dev/bhnd/nvram X-SVN-Commit-Revision: 331378 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Mar 2018 22:13:47 -0000 Author: landonf Date: Thu Mar 22 22:13:46 2018 New Revision: 331378 URL: https://svnweb.freebsd.org/changeset/base/331378 Log: Add missing NULL checks when calling malloc(M_NOWAIT) in bhnd_nv_strdup/bhnd_nv_strndup. If malloc(9) failed during initial bhnd(4) attach, while allocating the root NVRAM path string ("/"), the returned NULL pointer would be passed as the destination to memcpy(). Reported by: Ilja Van Sprundel Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_private.h Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_private.h ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram_private.h Thu Mar 22 21:57:10 2018 (r331377) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_private.h Thu Mar 22 22:13:46 2018 (r331378) @@ -91,6 +91,9 @@ bhnd_nv_strdup(const char *str) len = strlen(str); dest = malloc(len + 1, M_BHND_NVRAM, M_NOWAIT); + if (dest == NULL) + return (NULL); + memcpy(dest, str, len); dest[len] = '\0'; @@ -105,6 +108,9 @@ bhnd_nv_strndup(const char *str, size_t len) len = strnlen(str, len); dest = malloc(len + 1, M_BHND_NVRAM, M_NOWAIT); + if (dest == NULL) + return (NULL); + memcpy(dest, str, len); dest[len] = '\0';