summaryrefslogtreecommitdiff
path: root/source3/libsmb
diff options
context:
space:
mode:
authorChristopher R. Hertel <crh@samba.org>2000-07-12 04:25:12 +0000
committerChristopher R. Hertel <crh@samba.org>2000-07-12 04:25:12 +0000
commit8edb4966aeb8a8df6e5e348085450b6686bdc879 (patch)
tree6fd8922da77a959e63076723d59c0179729f21bd /source3/libsmb
parent5301a0954172519fdb00185b167d814869f46a98 (diff)
downloadsamba-8edb4966aeb8a8df6e5e348085450b6686bdc879.tar.gz
samba-8edb4966aeb8a8df6e5e348085450b6686bdc879.tar.bz2
samba-8edb4966aeb8a8df6e5e348085450b6686bdc879.zip
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 d8656304d51844335e72babe852673f2dececfdc)
Diffstat (limited to 'source3/libsmb')
-rw-r--r--source3/libsmb/namequery.c47
1 files changed, 37 insertions, 10 deletions
diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c
index 82c8c8f93d..193731768f 100644
--- a/source3/libsmb/namequery.c
+++ b/source3/libsmb/namequery.c
@@ -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;