From: Samuel Cabrero Date: Tue, 14 Jan 2020 16:12:33 +0000 (+0100) Subject: s3:libsmb: Fix querying all names registered within broadcast area X-Git-Tag: samba-4.12.0rc1~93 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2198da1b9bf79e86112aeeb8e9653f6a82f69e8d;p=thirdparty%2Fsamba.git s3:libsmb: Fix querying all names registered within broadcast area Wait for additional replies until timeout when '*' is given to nmblookup as name. Introduced by 8da8c36b53cc115f0d446b666fc24fc9423d808e. BUG: https://bugzilla.samba.org/show_bug.cgi?id=8927 Signed-off-by: Samuel Cabrero Reviewed-by: Jeremy Allison --- diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c index 5d4fca70b20..e27b60b0398 100644 --- a/source3/libsmb/namequery.c +++ b/source3/libsmb/namequery.c @@ -1221,6 +1221,7 @@ struct name_query_state { struct sockaddr_storage my_addr; struct sockaddr_storage addr; bool bcast; + bool bcast_star_query; uint8_t buf[1024]; @@ -1288,6 +1289,16 @@ struct tevent_req *name_query_send(TALLOC_CTX *mem_ctx, nmb->header.nscount = 0; nmb->header.arcount = 0; + if (bcast && (strcmp(name, "*")==0)) { + /* + * We're doing a broadcast query for all + * names in the area. Remember this so + * we will wait for all names within + * the timeout period. + */ + state->bcast_star_query = true; + } + make_nmb_name(&nmb->question.question_name,name,name_type); nmb->question.question_type = 0x20; @@ -1445,9 +1456,12 @@ static bool name_query_validator(struct packet_struct *p, void *private_data) if (state->bcast) { /* * We have to collect all entries coming in from broadcast - * queries. If we got a unique name, we're done. + * queries. If we got a unique name and we are not querying + * all names registered within broadcast area (query + * for the name '*', so state->bcast_star_query is set), + * we're done. */ - return got_unique_netbios_name; + return (got_unique_netbios_name && !state->bcast_star_query); } /* * WINS responses are accepted when they are received