File autofs-5.0.6-fix-ipv6-name-for-lookup-fix.patch of Package autofs.import5769

commit 2c6f2625bd6bdccad6a77f15c5066c7c325d4590
Author: Ian Kent <ikent@redhat.com>
Date:   Mon Jul 4 10:04:45 2011 +0800

    autofs-5.0.6 - fix ipv6 name for lookup fix
    
    Fix an error in the recent ipv6 name for lookup patch.
    
    Reported by Leonardo Chiquitto who provided a patch to resolve the
    problem. The patch below is a slightly modified version of his patch.

Index: autofs-5.0.5/modules/replicated.c
===================================================================
--- autofs-5.0.5.orig/modules/replicated.c
+++ autofs-5.0.5/modules/replicated.c
@@ -1111,7 +1111,8 @@ static int add_host_addrs(struct host **
 			  unsigned int weight, unsigned int options)
 {
 	struct addrinfo hints, *ni, *this;
-	char *name = strdup(host);
+	char *n_ptr;
+	char *name = n_ptr = strdup(host);
 	int len;
 	char buf[MAX_ERR_BUF];
 	int rr = 0;
@@ -1125,15 +1126,17 @@ static int add_host_addrs(struct host **
 	}
 	len = strlen(name);
 
-	if (name[0] == '[' && name[--len] == ']')
+	if (name[0] == '[' && name[--len] == ']') {
 		name[len] = '\0';
+		name++;
+	}
 
 	memset(&hints, 0, sizeof(hints));
 	hints.ai_flags = AI_NUMERICHOST;
 	hints.ai_family = AF_UNSPEC;
 	hints.ai_socktype = SOCK_DGRAM;
 
-	ret = getaddrinfo(name + 1, NULL, &hints, &ni);
+	ret = getaddrinfo(name, NULL, &hints, &ni);
 	if (ret)
 		goto try_name;
 
@@ -1153,7 +1156,7 @@ try_name:
 	hints.ai_family = AF_UNSPEC;
 	hints.ai_socktype = SOCK_DGRAM;
 
-	ret = getaddrinfo(name + 1, NULL, &hints, &ni);
+	ret = getaddrinfo(name, NULL, &hints, &ni);
 	if (ret) {
 		error(LOGOPT_ANY, "hostname lookup failed: %s",
 		      gai_strerror(ret));
@@ -1172,7 +1175,7 @@ try_name:
 	}
 	freeaddrinfo(ni);
 done:
-	free(name);
+	free(n_ptr);
 	return ret;
 }
 
Index: autofs-5.0.5/CHANGELOG
===================================================================
--- autofs-5.0.5.orig/CHANGELOG
+++ autofs-5.0.5/CHANGELOG
@@ -79,6 +79,7 @@
 - fix sasl bind host name selection.
 - fix ipv6 name for lookup.
 - fix libtirpc ipv6 check.
+- fix ipv6 name for lookup fix.
 
 03/09/2009 autofs-5.0.5
 -----------------------
openSUSE Build Service is sponsored by