diff options
author | Andrew Bartlett <abartlet@samba.org> | 2011-06-24 16:26:23 +1000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2011-06-24 16:26:23 +1000 |
commit | 6da26870e0ae5acd6ff49a30ec2f6886b44d095e (patch) | |
tree | 850c71039563c16a5d563c47e7ba2ab645baf198 /nsswitch/wins.c | |
parent | 6925a799d04c6fa59dd2ddef1f5510f9bb7d17d1 (diff) | |
parent | 2610c05b5b95cc7036b3d6dfb894c6cfbdb68483 (diff) | |
download | samba-6da26870e0ae5acd6ff49a30ec2f6886b44d095e.tar.gz samba-6da26870e0ae5acd6ff49a30ec2f6886b44d095e.tar.bz2 samba-6da26870e0ae5acd6ff49a30ec2f6886b44d095e.zip |
Merge 2610c05b5b95cc7036b3d6dfb894c6cfbdb68483 as Samba-4.0alpha16
Diffstat (limited to 'nsswitch/wins.c')
-rw-r--r-- | nsswitch/wins.c | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/nsswitch/wins.c b/nsswitch/wins.c index e0aa2ad8f5..d63968b2bc 100644 --- a/nsswitch/wins.c +++ b/nsswitch/wins.c @@ -59,8 +59,10 @@ static void nss_wins_init(void) static struct in_addr *lookup_byname_backend(const char *name, int *count) { - struct ip_service *address = NULL; + TALLOC_CTX *frame = talloc_stackframe(); + struct sockaddr_storage *address = NULL; struct in_addr *ret = NULL; + NTSTATUS status; int j; if (!initialised) { @@ -70,19 +72,21 @@ static struct in_addr *lookup_byname_backend(const char *name, int *count) *count = 0; /* always try with wins first */ - if (NT_STATUS_IS_OK(resolve_wins(name,0x00,&address,count))) { + status = resolve_wins(name, 0x00, talloc_tos(), + &address, count); + if (NT_STATUS_IS_OK(status)) { if ( (ret = SMB_MALLOC_P(struct in_addr)) == NULL ) { - free( address ); + TALLOC_FREE(frame); return NULL; } - if (address[0].ss.ss_family != AF_INET) { - free(address); + if (address[0].ss_family != AF_INET) { free(ret); + TALLOC_FREE(frame); return NULL; } - *ret = ((struct sockaddr_in *)(void *)&address[0].ss) + *ret = ((struct sockaddr_in *)(void *)address) ->sin_addr; - free( address ); + TALLOC_FREE(frame); return ret; } @@ -91,24 +95,23 @@ static struct in_addr *lookup_byname_backend(const char *name, int *count) const struct in_addr *bcast = iface_n_bcast_v4(j); struct sockaddr_storage ss; struct sockaddr_storage *pss; - NTSTATUS status; if (!bcast) { continue; } in_addr_to_sockaddr_storage(&ss, *bcast); status = name_query(name, 0x00, True, True, &ss, - NULL, &pss, count, NULL); - if (pss) { + talloc_tos(), &pss, count, NULL); + if (NT_STATUS_IS_OK(status) && (*count > 0)) { if ((ret = SMB_MALLOC_P(struct in_addr)) == NULL) { + TALLOC_FREE(frame); return NULL; } *ret = ((struct sockaddr_in *)pss)->sin_addr; - TALLOC_FREE(pss); break; } } - + TALLOC_FREE(frame); return ret; } @@ -180,7 +183,7 @@ int lookup(nsd_file_t *rq) * response needs to be a string of the following format * ip_address[ ip_address]*\tname[ alias]* */ - if (StrCaseCmp(map,"hosts.byaddr") == 0) { + if (strcasecmp_m(map,"hosts.byaddr") == 0) { if ( status = lookup_byaddr_backend(key, &count)) { size = strlen(key) + 1; if (size > len) { @@ -208,7 +211,7 @@ int lookup(nsd_file_t *rq) response[strlen(response)-1] = '\n'; talloc_free(status); } - } else if (StrCaseCmp(map,"hosts.byname") == 0) { + } else if (strcasecmp_m(map,"hosts.byname") == 0) { if (ip_list = lookup_byname_backend(key, &count)) { for (i = count; i ; i--) { addr = inet_ntoa(ip_list[i-1]); |