On Wed, 2011-06-29 at 11:39 -0300, Leonardo Chiquitto wrote:
> Fix non-IPv6 host name lookups
> 
> Commit 5b083026 ("fix ipv6 name for lookup") causes a regression
> in regular (non-IPv6) host name lookups: it trims the first host
> name character even when it's not a "[". This patch fixes the issue.

Gaah .... yep.

> 
> ---
>  modules/replicated.c |    8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> Index: autofs/modules/replicated.c
> ===================================================================
> --- autofs.orig/modules/replicated.c
> +++ autofs/modules/replicated.c
> @@ -1125,15 +1125,17 @@ static int add_host_addrs(struct host **
>       }
>       len = strlen(name);
>  
> -     if (name[0] == '[' && name[--len] == ']')
> +     if (name[0] == '[' && name[--len] == ']') {
>               name[len] = '\0';
> +             memmove(name, name + 1, len);
> +     }
>  
>       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 +1155,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));
> 
> _______________________________________________
> autofs mailing list
> autofs@linux.kernel.org
> http://linux.kernel.org/mailman/listinfo/autofs


_______________________________________________
autofs mailing list
autofs@linux.kernel.org
http://linux.kernel.org/mailman/listinfo/autofs

Reply via email to