Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 30 Jun 2017 07:04:10 +0000 (UTC)
From:      Xin LI <delphij@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r320494 - head/lib/libc/rpc
Message-ID:  <201706300704.v5U74ABh065339@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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++) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201706300704.v5U74ABh065339>