diff options
author | markj <markj@FreeBSD.org> | 2016-05-29 19:46:34 +0000 |
---|---|---|
committer | markj <markj@FreeBSD.org> | 2016-05-29 19:46:34 +0000 |
commit | 1ae96dc8dbea2290d14c8d47d035e31676b93982 (patch) | |
tree | 15d4dd2dc321ed1ffb0ebc5eab4266ca5df9b5d8 /usr.sbin/rpcbind/util.c | |
parent | 1bed4ff78e79c492978e96fb7773019843025c46 (diff) | |
download | FreeBSD-src-1ae96dc8dbea2290d14c8d47d035e31676b93982.zip FreeBSD-src-1ae96dc8dbea2290d14c8d47d035e31676b93982.tar.gz |
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
Diffstat (limited to 'usr.sbin/rpcbind/util.c')
-rw-r--r-- | usr.sbin/rpcbind/util.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/usr.sbin/rpcbind/util.c b/usr.sbin/rpcbind/util.c index 814a379..7ada376 100644 --- a/usr.sbin/rpcbind/util.c +++ b/usr.sbin/rpcbind/util.c @@ -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); */ } |