Skip to content

Commit

Permalink
Fix rpcbind init after r300941.
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
markjdb committed May 29, 2016
1 parent 1bed4ff commit 1ae96dc
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion usr.sbin/rpcbind/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ network_init(void)
exit(1);
}
memcpy(local_in4, res->ai_addr, sizeof *local_in4);
freeaddrinfo(res);
}

#ifdef INET6
Expand All @@ -354,6 +355,7 @@ network_init(void)
exit(1);
}
memcpy(local_in6, res->ai_addr, sizeof *local_in6);
freeaddrinfo(res);
}

/*
Expand Down Expand Up @@ -395,7 +397,6 @@ network_init(void)
freeifaddrs(ifp);
#endif

freeaddrinfo(res);
/* close(s); */
}

Expand Down

0 comments on commit 1ae96dc

Please sign in to comment.