From: Jeremy Allison Date: Fri, 27 Apr 2012 23:07:20 +0000 (-0700) Subject: Fix convert_ss2service() to filter out zero addresses. X-Git-Tag: samba-4.0.0alpha20~5 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=50766a72f9ce42d9f5fd2ce713c9b3039aa8bc2b;p=thirdparty%2Fsamba.git Fix convert_ss2service() to filter out zero addresses. --- diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c index 0f2c66f32a9..494836d4b28 100644 --- a/source3/libsmb/namequery.c +++ b/source3/libsmb/namequery.c @@ -1513,32 +1513,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