r16213: Fix Klocwork #852. iface_n_ip can potentially
authorJeremy Allison <jra@samba.org>
Wed, 14 Jun 2006 00:37:52 +0000 (00:37 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 16:17:26 +0000 (11:17 -0500)
return NULL. Ensure we don't deref.
Jeremy.
(This used to be commit c2f0ea2ff2f6ad925cee9c85110c6ad828ffb7a9)

source3/nmbd/nmbd_become_dmb.c
source3/nmbd/nmbd_subnetdb.c

index fb1fb33a8180f379bd2b0dedd91414b0b1e7792a..523ec6cabf1429c8753b4c58f4aff1509191ee84 100644 (file)
@@ -120,6 +120,7 @@ in workgroup %s on subnet %s\n",
        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,7 +131,14 @@ in workgroup %s on subnet %s\n",
 
                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);
 
index c3640028d27a30b45483ea6b9a62fc7a87516932..5a93d8bec03eb6116d7b6f19305aef7a101964c6 100644 (file)
@@ -220,7 +220,13 @@ BOOL create_subnets(void)
 
        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