1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-11 05:18:09 +03:00

An improved version of the Negative Query Response fix. The earlier fix

only did a short-cut on an rcode of 3, which is 'name not found'.  This
does a short-cut on any non-zero rcode.  It also puts out a DEBUG message
(if DEBUGLEVEL is >= 3) detailing the error.

Chris -)-----
(This used to be commit d8656304d5)
This commit is contained in:
Christopher R. Hertel 2000-07-12 04:25:12 +00:00
parent 5301a09541
commit 8edb4966ae

View File

@ -272,16 +272,42 @@ struct in_addr *name_query(int fd,const char *name,int name_type,
struct nmb_packet *nmb2 = &p2->packet.nmb;
debug_nmb_packet(p2);
/* If we get a Negative Name Query Response from a WINS
* server, we should report it and give up.
*/
if( 0 == nmb2->header.opcode /* A query response */
&& !(bcast) /* from a WINS server */
&& 0x03 == nmb2->header.rcode /* Name doesn't exist */
&& nmb2->header.rcode /* Error returned */
) {
/* If we get a Negative Name Query Response from a WINS
* server, we should give up.
*/
free_packet(p2);
return( NULL );
if( DEBUGLVL( 3 ) ) {
/* Only executed if DEBUGLEVEL >= 3 */
dbgtext( "Negative name query response, rcode 0x%02x: ",
nmb2->header.rcode );
switch( nmb2->header.rcode ) {
case 0x01:
dbgtext( "Request was invalidly formatted.\n" );
break;
case 0x02:
dbgtext( "Problem with NBNS, cannot process name.\n");
break;
case 0x03:
dbgtext( "The name requested does not exist.\n" );
break;
case 0x04:
dbgtext( "Unsupported request error.\n" );
break;
case 0x05:
dbgtext( "Refused error.\n" );
break;
default:
dbgtext( "Unrecognized error code.\n" );
break;
}
}
free_packet(p2);
return( NULL );
}
if (nmb2->header.opcode != 0 ||
nmb2->header.nm_flags.bcast ||
@ -295,17 +321,18 @@ struct in_addr *name_query(int fd,const char *name,int name_type,
continue;
}
ip_list = (struct in_addr *)Realloc(ip_list, sizeof(ip_list[0]) *
((*count)+nmb2->answers->rdlength/6));
ip_list = (struct in_addr *)Realloc( ip_list,
sizeof( ip_list[0] )
* ( (*count) + nmb2->answers->rdlength/6 ) );
if (ip_list) {
DEBUG(2,("Got a positive name query response from %s ( ",
inet_ntoa(p2->ip)));
for (i=0;i<nmb2->answers->rdlength/6;i++) {
putip((char *)&ip_list[(*count)],&nmb2->answers->rdata[2+i*6]);
DEBUG(2,("%s ",inet_ntoa(ip_list[(*count)])));
DEBUGADD(2,("%s ",inet_ntoa(ip_list[(*count)])));
(*count)++;
}
DEBUG(2,(")\n"));
DEBUGADD(2,(")\n"));
}
found=True;