From owner-svn-src-head@freebsd.org Fri Dec 30 23:44:40 2016 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 71D9FC98260; Fri, 30 Dec 2016 23:44:40 +0000 (UTC) (envelope-from ngie@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 416F41E12; Fri, 30 Dec 2016 23:44:40 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBUNidLv063907; Fri, 30 Dec 2016 23:44:39 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBUNidMT063906; Fri, 30 Dec 2016 23:44:39 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201612302344.uBUNidMT063906@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Fri, 30 Dec 2016 23:44:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310873 - head/contrib/bsnmp/snmp_mibII 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: Fri, 30 Dec 2016 23:44:40 -0000 Author: ngie Date: Fri Dec 30 23:44:39 2016 New Revision: 310873 URL: https://svnweb.freebsd.org/changeset/base/310873 Log: Guard against use-after-free after calling mibif_free(..) Set variables to NULL after calling free. Also, remove unnecessary if (x != NULL) checks before calling free(x) MFC after: 1 week Modified: head/contrib/bsnmp/snmp_mibII/mibII.c Modified: head/contrib/bsnmp/snmp_mibII/mibII.c ============================================================================== --- head/contrib/bsnmp/snmp_mibII/mibII.c Fri Dec 30 23:41:33 2016 (r310872) +++ head/contrib/bsnmp/snmp_mibII/mibII.c Fri Dec 30 23:44:39 2016 (r310873) @@ -707,10 +707,11 @@ mibif_free(struct mibif *ifp) } free(ifp->private); - if (ifp->physaddr != NULL) - free(ifp->physaddr); - if (ifp->specmib != NULL) - free(ifp->specmib); + ifp->private = NULL; + free(ifp->physaddr); + ifp->physaddr = NULL; + free(ifp->specmib); + ifp->specmib = NULL; STAILQ_FOREACH(map, &mibindexmap_list, link) if (map->mibif == ifp) { @@ -745,8 +746,8 @@ mibif_free(struct mibif *ifp) at = at1; } - free(ifp); + ifp = NULL; mib_if_number--; mib_iftable_last_change = this_tick; }