git.samba.org
/
ddiss
/
samba.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
d7bddfe
)
Fix convert_ss2service() to filter out zero addresses.
author
Jeremy Allison
<jra@samba.org>
Mon, 30 Apr 2012 21:45:43 +0000
(14:45 -0700)
committer
Karolin Seeger
<kseeger@samba.org>
Sat, 26 May 2012 20:15:23 +0000
(22:15 +0200)
source3/libsmb/namequery.c
patch
|
blob
|
history
diff --git
a/source3/libsmb/namequery.c
b/source3/libsmb/namequery.c
index 018725e3c1083db6198a463c8b584214655fd371..15cb97cf5f2ee76c0ace70ca054fdcf37d0c2ddd 100644
(file)
--- a/
source3/libsmb/namequery.c
+++ b/
source3/libsmb/namequery.c
@@
-1475,32
+1475,53
@@
NTSTATUS name_query(const char *name, int name_type,
}
/********************************************************
}
/********************************************************
-
c
onvert an array if struct sockaddr_storage to struct ip_service
+
C
onvert an array if struct sockaddr_storage to struct ip_service
return false on failure. Port is set to PORT_NONE;
return false on failure. Port is set to PORT_NONE;
+ pcount is [in/out] - it is the length of ss_list on input,
+ and the length of return_iplist on output as we remove any
+ zero addresses from ss_list.
*********************************************************/
static bool convert_ss2service(struct ip_service **return_iplist,
const struct sockaddr_storage *ss_list,
*********************************************************/
static bool convert_ss2service(struct ip_service **return_iplist,
const struct sockaddr_storage *ss_list,
- int count)
+ int
*p
count)
{
int i;
{
int i;
+ int orig_count = *pcount;
+ int real_count = 0;
- if (
count==0 || !ss_list )
+ if (
orig_
count==0 || !ss_list )
return False;
return False;
+ /* Filter out zero addrs. */
+ for ( i=0; i<orig_count; i++ ) {
+ if (is_zero_addr(&ss_list[i])) {
+ continue;
+ }
+ real_count++;
+ }
+ if (real_count==0) {
+ return false;
+ }
+
/* copy the ip address; port will be PORT_NONE */
/* copy the ip address; port will be PORT_NONE */
- if ((*return_iplist = SMB_MALLOC_ARRAY(struct ip_service, count)) ==
+ if ((*return_iplist = SMB_MALLOC_ARRAY(struct ip_service,
real_
count)) ==
NULL) {
DEBUG(0,("convert_ip2service: malloc failed "
NULL) {
DEBUG(0,("convert_ip2service: malloc failed "
- "for %d enetries!\n", count ));
+ "for %d enetries!\n",
real_
count ));
return False;
}
return False;
}
- for ( i=0; i<count; i++ ) {
- (*return_iplist)[i].ss = ss_list[i];
- (*return_iplist)[i].port = PORT_NONE;
- }
+ for ( i=0, real_count = 0; i<orig_count; i++ ) {
+ if (is_zero_addr(&ss_list[i])) {
+ continue;
+ }
+ (*return_iplist)[real_count].ss = ss_list[i];
+ (*return_iplist)[real_count].port = PORT_NONE;
+ real_count++;
+ }
+ *pcount = real_count;
return true;
}
return true;
}
@@
-1684,7
+1705,7
@@
NTSTATUS resolve_wins(const char *name,
success:
status = NT_STATUS_OK;
success:
status = NT_STATUS_OK;
- if (!convert_ss2service(return_iplist, ss_list,
*
return_count))
+ if (!convert_ss2service(return_iplist, ss_list, return_count))
status = NT_STATUS_INVALID_PARAMETER;
TALLOC_FREE(ss_list);
status = NT_STATUS_INVALID_PARAMETER;
TALLOC_FREE(ss_list);
@@
-1728,7
+1749,7
@@
static NTSTATUS resolve_lmhosts(const char *name, int name_type,
if (NT_STATUS_IS_OK(status)) {
if (convert_ss2service(return_iplist,
ss_list,
if (NT_STATUS_IS_OK(status)) {
if (convert_ss2service(return_iplist,
ss_list,
-
*
return_count)) {
+ return_count)) {
talloc_free(ctx);
return NT_STATUS_OK;
} else {
talloc_free(ctx);
return NT_STATUS_OK;
} else {
@@
-2073,7
+2094,7
@@
NTSTATUS internal_resolve_name(const char *name,
if (NT_STATUS_IS_OK(status)) {
if (!convert_ss2service(return_iplist,
ss_list,
if (NT_STATUS_IS_OK(status)) {
if (!convert_ss2service(return_iplist,
ss_list,
-
*
return_count)) {
+ return_count)) {
status = NT_STATUS_NO_MEMORY;
}
goto done;
status = NT_STATUS_NO_MEMORY;
}
goto done;