Blob Blame History Raw
autofs-5.1.0 - fix memory leak in create_client()

From: Ian Kent <raven@themaw.net>

In create_client(), if the target host is unreachable the function
exists without freeing the addrinfo data returned from getaddrinfo(3).
---
 CHANGELOG      |    1 +
 lib/rpc_subs.c |    4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)

--- autofs-5.0.7.orig/CHANGELOG
+++ autofs-5.0.7/CHANGELOG
@@ -148,6 +148,7 @@
 - add mutex call return check in defaults.c.
 - force disable browse mode for amd format maps.
 - fix hosts map options check in lookup_amd_instance().
+- fix memory leak in create_client().
 
 25/07/2012 autofs-5.0.7
 =======================
--- autofs-5.0.7.orig/lib/rpc_subs.c
+++ autofs-5.0.7/lib/rpc_subs.c
@@ -719,8 +719,10 @@ static int create_client(struct conn_inf
 		ret = rpc_do_create_client(haddr->ai_addr, info, &fd, client);
 		if (ret == 0)
 			break;
-		if (ret == -EHOSTUNREACH)
+		if (ret == -EHOSTUNREACH) {
+			freeaddrinfo(ai);
 			goto out_close;
+		}
 
 		if (!info->client && fd != RPC_ANYSOCK) {
 			close(fd);