Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 29 May 2016 19:46:34 +0000 (UTC)
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r300972 - head/usr.sbin/rpcbind
Message-ID:  <201605291946.u4TJkYXf002602@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: markj
Date: Sun May 29 19:46:34 2016
New Revision: 300972
URL: https://svnweb.freebsd.org/changeset/base/300972

Log:
  Fix rpcbind init after r300941.
  
  - getaddrinfo() sets res = NULL on failure and freeaddrinfo() always
    dereferences its argument, so we should only free the address list after
    a successful call.
  - Address a second potential leak caused by getaddrinfo(AF_INET6)
    overwriting the address list returned by getaddrinfo(AF_INET).
  
  X-MFC-With:	r300941

Modified:
  head/usr.sbin/rpcbind/util.c

Modified: head/usr.sbin/rpcbind/util.c
==============================================================================
--- head/usr.sbin/rpcbind/util.c	Sun May 29 19:35:55 2016	(r300971)
+++ head/usr.sbin/rpcbind/util.c	Sun May 29 19:46:34 2016	(r300972)
@@ -338,6 +338,7 @@ network_init(void)
 			exit(1);
 		}
 		memcpy(local_in4, res->ai_addr, sizeof *local_in4);
+		freeaddrinfo(res);
 	}
 
 #ifdef INET6
@@ -354,6 +355,7 @@ network_init(void)
 			exit(1);
 		}
 		memcpy(local_in6, res->ai_addr, sizeof *local_in6);
+		freeaddrinfo(res);
 	}
 
 	/*
@@ -395,7 +397,6 @@ network_init(void)
 	freeifaddrs(ifp);
 #endif
 
-	freeaddrinfo(res);
 	/* close(s); */
 }
 



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