Blob Blame History Raw
autofs-5.1.3 - workaround getaddrinfo(3) ai_canonname bug

From: Ian Kent <raven@themaw.net>

There appears to be a bug in some versions of getaddrinfo() where the
addrinfo structure gets garbage in ai_canonname when it is not requested
by the lookup flags causing a crash or lookup fail.

Try and work around this by always requesting ai_canonname for lookups
and hope this doesn't affect the semantics of the autofs lookup usage.

Signed-off-by: Ian Kent <raven@themaw.net>
---
 CHANGELOG            |    1 +
 lib/parse_subs.c     |    1 +
 lib/rpc_subs.c       |    2 +-
 modules/parse_amd.c  |    2 +-
 modules/replicated.c |    4 ++--
 5 files changed, 6 insertions(+), 4 deletions(-)

--- autofs-5.0.7.orig/CHANGELOG
+++ autofs-5.0.7/CHANGELOG
@@ -324,6 +324,7 @@
 - log mount call arguments if mount_verbose is set.
 - document ghost option in auto.master man page.
 - make expire remaining log level debug.
+- workaround getaddrinfo(3) ai_canonname bug
 
 25/07/2012 autofs-5.0.7
 =======================
--- autofs-5.0.7.orig/lib/parse_subs.c
+++ autofs-5.0.7/lib/parse_subs.c
@@ -472,6 +472,7 @@ unsigned int get_network_proximity(const
 	memset(&hints, 0, sizeof(struct addrinfo));
 	hints.ai_family = AF_UNSPEC;
 	hints.ai_socktype = SOCK_DGRAM;
+	hints.ai_flags = AI_V4MAPPED | AI_ADDRCONFIG | AI_CANONNAME;
 
 	ret = getaddrinfo(name_or_num, NULL, &hints, &ni);
 	if (ret) {
--- autofs-5.0.7.orig/lib/rpc_subs.c
+++ autofs-5.0.7/lib/rpc_subs.c
@@ -692,7 +692,7 @@ static int create_client(struct conn_inf
 	}
 
 	memset(&hints, 0, sizeof(hints));
-	hints.ai_flags = AI_ADDRCONFIG;
+	hints.ai_flags = AI_ADDRCONFIG | AI_CANONNAME;
 	hints.ai_family = AF_UNSPEC;
 	if (info->proto == IPPROTO_UDP)
 		hints.ai_socktype = SOCK_DGRAM;
--- autofs-5.0.7.orig/modules/parse_amd.c
+++ autofs-5.0.7/modules/parse_amd.c
@@ -264,7 +264,7 @@ static int match_my_name(unsigned int lo
 		goto out;
 	}
 
-	hints.ai_flags = 0;
+	hints.ai_flags = AI_V4MAPPED | AI_ADDRCONFIG | AI_CANONNAME;
 
 	/* Resolve comparison name to its names and compare */
 	ret = getaddrinfo(name, NULL, &hints, &ni);
--- autofs-5.0.7.orig/modules/replicated.c
+++ autofs-5.0.7/modules/replicated.c
@@ -919,7 +919,7 @@ static int add_host_addrs(struct host **
 	}
 
 	memset(&hints, 0, sizeof(hints));
-	hints.ai_flags = AI_NUMERICHOST;
+	hints.ai_flags = AI_NUMERICHOST | AI_CANONNAME;
 	hints.ai_family = AF_UNSPEC;
 	hints.ai_socktype = SOCK_DGRAM;
 
@@ -939,7 +939,7 @@ static int add_host_addrs(struct host **
 
 try_name:
 	memset(&hints, 0, sizeof(hints));
-	hints.ai_flags = AI_ADDRCONFIG;
+	hints.ai_flags = AI_ADDRCONFIG | AI_CANONNAME;
 	hints.ai_family = AF_UNSPEC;
 	hints.ai_socktype = SOCK_DGRAM;