From 9b9a3d6b04a1667751248545b63c192f3ce69f9b Mon Sep 17 00:00:00 2001 From: Tom Mortensen Date: Sat, 16 Apr 2016 10:57:12 +0200 Subject: [PATCH 1/2] nss_wins: ip_pton expects the raw IP address BUG: https://bugzilla.samba.org/show_bug.cgi?id=11875 Signed-off-by: Tom Mortensen Reviewed-by: Volker Lendecke Reviewed-by: Jeremy Allison (cherry picked from commit d3569ca2711d21ac87ff539662333ad315a2a618) --- nsswitch/wins.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/nsswitch/wins.c b/nsswitch/wins.c index 3243ffb..22524e4 100644 --- a/nsswitch/wins.c +++ b/nsswitch/wins.c @@ -47,7 +47,7 @@ NSS_STATUS _nss_wins_gethostbyname2_r(const char *name, int af, struct hostent * static char *lookup_byname_backend(const char *name) { const char *p; - char *ip; + char *ip, *ipp; size_t nbt_len; wbcErr result; @@ -65,6 +65,11 @@ static char *lookup_byname_backend(const char *name) return NULL; } + ipp = strchr(ip, '\t'); + if (ipp != NULL) { + *ipp = '\0'; + } + return ip; } -- 2.8.1 From e8b76fa508dca1098a780841db5f27d45062e8d4 Mon Sep 17 00:00:00 2001 From: Tom Mortensen Date: Sat, 16 Apr 2016 10:57:12 +0200 Subject: [PATCH 2/2] nss_wins: Fix the hostent setup This can never have been tested.... BUG: https://bugzilla.samba.org/show_bug.cgi?id=11875 Signed-off-by: Tom Mortensen Reviewed-by: Volker Lendecke Reviewed-by: Jeremy Allison (cherry picked from commit 0b1f4db325bb0ed9171619c874908ee25327bba9) --- nsswitch/wins.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nsswitch/wins.c b/nsswitch/wins.c index 22524e4..fc65c03 100644 --- a/nsswitch/wins.c +++ b/nsswitch/wins.c @@ -280,7 +280,7 @@ _nss_wins_gethostbyname_r(const char *hostname, struct hostent *he, } if ((he->h_addr_list = (char **)get_static( - &buffer, &buflen, i * sizeof(char *))) == NULL) { + &buffer, &buflen, 2 * sizeof(char *))) == NULL) { nss_status = NSS_STATUS_TRYAGAIN; goto out; } @@ -291,9 +291,9 @@ _nss_wins_gethostbyname_r(const char *hostname, struct hostent *he, goto out; } - memcpy(he->h_addr_list[i], &in, INADDRSZ); + memcpy(he->h_addr_list[0], &in, INADDRSZ); - he->h_addr_list[0] = NULL; + he->h_addr_list[1] = NULL; /* Set h_addr_type and h_length */ -- 2.8.1