From d259cd40204108d262b6b3c18d1f2a9f9d0fee42 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 30 Apr 2012 14:45:43 -0700 Subject: [PATCH] Fix convert_ss2service() to filter out zero addresses. --- source3/libsmb/namequery.c | 45 ++++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c index 018725e3c10..15cb97cf5f2 100644 --- a/source3/libsmb/namequery.c +++ b/source3/libsmb/namequery.c @@ -1475,32 +1475,53 @@ NTSTATUS name_query(const char *name, int name_type, } /******************************************************** - convert an array if struct sockaddr_storage to struct ip_service + Convert an array if struct sockaddr_storage to struct ip_service 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, - int count) + int *pcount) { int i; + int orig_count = *pcount; + int real_count = 0; - if ( count==0 || !ss_list ) + if (orig_count==0 || !ss_list ) return False; + /* Filter out zero addrs. */ + for ( i=0; i