From 3226be5b5ab771c8cdf98588c40713d36eae4702 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 30 Apr 2012 16:24:27 -0700 Subject: [PATCH] Fix convert_ss2service() to filter out zero addresses. --- source3/libsmb/namequery.c | 41 +++++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c index ff43706175f..b68448e16ae 100644 --- a/source3/libsmb/namequery.c +++ b/source3/libsmb/namequery.c @@ -848,32 +848,53 @@ struct sockaddr_storage *name_query(int fd, } /******************************************************** - 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