]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
netmap: fix coverity warning 1362789
authorVictor Julien <victor@inliniac.net>
Tue, 21 Jun 2016 11:21:54 +0000 (13:21 +0200)
committerVictor Julien <victor@inliniac.net>
Tue, 21 Jun 2016 11:21:54 +0000 (13:21 +0200)
** CID 1362789:  Null pointer dereferences  (FORWARD_NULL)
/src/runmode-netmap.c: 247 in ParseNetmapConfig()

________________________________________________________________________________________________________
*** CID 1362789:  Null pointer dereferences  (FORWARD_NULL)
/src/runmode-netmap.c: 247 in ParseNetmapConfig()
241         strlcpy(aconf->iface_name, iface_name, sizeof(aconf->iface_name));
242         SC_ATOMIC_INIT(aconf->ref);
243         (void) SC_ATOMIC_ADD(aconf->ref, 1);
244
245         /* Find initial node */
246         netmap_node = ConfGetNode("netmap");
>>>     CID 1362789:  Null pointer dereferences  (FORWARD_NULL)
>>>     Comparing "netmap_node" to null implies that "netmap_node" might be null.
247         if (netmap_node == NULL) {
248             SCLogInfo("Unable to find netmap config using default value");
249         } else {
250             if_root = ConfFindDeviceConfig(netmap_node, aconf->iface_name);
251             if_default = ConfFindDeviceConfig(netmap_node, "default");
252         }

src/runmode-netmap.c

index 81c409c2835eddfbc139257f2cf5a4bb91cbe18a..1cf08bc8298709b54e42bddca222ea8690a2ed0b 100644 (file)
@@ -255,10 +255,12 @@ static void *ParseNetmapConfig(const char *iface_name)
     ParseNetmapSettings(&aconf->in, aconf->iface_name, if_root, if_default);
 
     /* if we have a copy iface, parse that as well */
-    if (ConfGetChildValueWithDefault(if_root, if_default, "copy-iface", &out_iface) == 1) {
-        if (strlen(out_iface) > 0) {
-            if_root = ConfFindDeviceConfig(netmap_node, out_iface);
-            ParseNetmapSettings(&aconf->out, out_iface, if_root, if_default);
+    if (netmap_node != NULL) {
+        if (ConfGetChildValueWithDefault(if_root, if_default, "copy-iface", &out_iface) == 1) {
+            if (strlen(out_iface) > 0) {
+                if_root = ConfFindDeviceConfig(netmap_node, out_iface);
+                ParseNetmapSettings(&aconf->out, out_iface, if_root, if_default);
+            }
         }
     }