svn commit: samba r16213 - in branches/SAMBA_3_0/source/nmbd: .

jra at samba.org jra at samba.org
Wed Jun 14 00:37:53 GMT 2006


Author: jra
Date: 2006-06-14 00:37:52 +0000 (Wed, 14 Jun 2006)
New Revision: 16213

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=16213

Log:
Fix Klocwork #852. iface_n_ip can potentially
return NULL. Ensure we don't deref.
Jeremy.

Modified:
   branches/SAMBA_3_0/source/nmbd/nmbd_become_dmb.c
   branches/SAMBA_3_0/source/nmbd/nmbd_subnetdb.c


Changeset:
Modified: branches/SAMBA_3_0/source/nmbd/nmbd_become_dmb.c
===================================================================
--- branches/SAMBA_3_0/source/nmbd/nmbd_become_dmb.c	2006-06-14 00:37:46 UTC (rev 16212)
+++ branches/SAMBA_3_0/source/nmbd/nmbd_become_dmb.c	2006-06-14 00:37:52 UTC (rev 16213)
@@ -120,6 +120,7 @@
 	if( subrec == unicast_subnet ) {
 		struct nmb_name nmbname;
 		struct in_addr my_first_ip;
+		struct in_addr *nip;
 
 		/* Put our name and first IP address into the 
 		   workgroup struct as domain master browser. This
@@ -130,8 +131,15 @@
 
 		work->dmb_name = nmbname;
 		/* Pick the first interface ip address as the domain master browser ip. */
-		my_first_ip = *iface_n_ip(0);
+		nip = iface_n_ip(0);
 
+		if (!nip) {
+			DEBUG(0,("become_domain_master_stage2: Error. iface_n_ip returned NULL\n"));
+			return;
+		}
+
+		my_first_ip = *nip;
+
 		putip((char *)&work->dmb_addr, &my_first_ip);
 
 		/* We successfully registered by unicast with the

Modified: branches/SAMBA_3_0/source/nmbd/nmbd_subnetdb.c
===================================================================
--- branches/SAMBA_3_0/source/nmbd/nmbd_subnetdb.c	2006-06-14 00:37:46 UTC (rev 16212)
+++ branches/SAMBA_3_0/source/nmbd/nmbd_subnetdb.c	2006-06-14 00:37:52 UTC (rev 16213)
@@ -220,7 +220,13 @@
 
 	if (lp_we_are_a_wins_server()) {
 		/* Pick the first interface ip address as the WINS server ip. */
-		unicast_ip = *iface_n_ip(0);
+		struct in_addr *nip = iface_n_ip(0);
+
+		if (!nip) {
+			return False;
+		}
+
+		unicast_ip = *nip;
 	} else {
 		/* note that we do not set the wins server IP here. We just
 			set it at zero and let the wins registration code cope



More information about the samba-cvs mailing list