From owner-svn-src-head@freebsd.org Fri Jun 30 07:04:11 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 C921DD8A0BA; Fri, 30 Jun 2017 07:04:11 +0000 (UTC) (envelope-from delphij@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 8AC2082CE8; Fri, 30 Jun 2017 07:04:11 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v5U74A7m065340; Fri, 30 Jun 2017 07:04:10 GMT (envelope-from delphij@FreeBSD.org) Received: (from delphij@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v5U74ABh065339; Fri, 30 Jun 2017 07:04:10 GMT (envelope-from delphij@FreeBSD.org) Message-Id: <201706300704.v5U74ABh065339@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: delphij set sender to delphij@FreeBSD.org using -f From: Xin LI Date: Fri, 30 Jun 2017 07:04:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r320494 - head/lib/libc/rpc X-SVN-Group: head X-SVN-Commit-Author: delphij X-SVN-Commit-Paths: head/lib/libc/rpc X-SVN-Commit-Revision: 320494 X-SVN-Commit-Repository: base 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 Jun 2017 07:04:11 -0000 Author: delphij Date: Fri Jun 30 07:04:10 2017 New Revision: 320494 URL: https://svnweb.freebsd.org/changeset/base/320494 Log: Revert r300385 and r300624 which was false positive reported by cppcheck. dup_ncp() tries to allocate a buffer of MAXNETCONFIGLINE as tmp, which is then assigned to p->nc_netid via strcpy, so the free(p->nc_netid) would have correctly released the memory in case nc_lookups() fails, therefore, the allerged leak never existed. MFC after: 3 days Modified: head/lib/libc/rpc/getnetconfig.c Modified: head/lib/libc/rpc/getnetconfig.c ============================================================================== --- head/lib/libc/rpc/getnetconfig.c Fri Jun 30 06:34:49 2017 (r320493) +++ head/lib/libc/rpc/getnetconfig.c Fri Jun 30 07:04:10 2017 (r320494) @@ -692,7 +692,7 @@ static struct netconfig * dup_ncp(struct netconfig *ncp) { struct netconfig *p; - char *tmp, *tmp2; + char *tmp; u_int i; if ((tmp=malloc(MAXNETCONFIGLINE)) == NULL) @@ -701,7 +701,6 @@ dup_ncp(struct netconfig *ncp) free(tmp); return(NULL); } - tmp2 = tmp; /* * First we dup all the data from matched netconfig buffer. Then we * adjust some of the member pointer to a pre-allocated buffer where @@ -723,7 +722,6 @@ dup_ncp(struct netconfig *ncp) if (p->nc_lookups == NULL) { free(p->nc_netid); free(p); - free(tmp2); return(NULL); } for (i=0; i < p->nc_nlookups; i++) {