From: Victor Julien Date: Tue, 21 Jun 2016 11:21:54 +0000 (+0200) Subject: netmap: fix coverity warning 1362789 X-Git-Tag: suricata-3.1.1~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ab65b6f83b55e12fb05aafcaf51ad9b369b82de5;p=thirdparty%2Fsuricata.git netmap: fix coverity warning 1362789 ** 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 } --- diff --git a/src/runmode-netmap.c b/src/runmode-netmap.c index 81c409c283..1cf08bc829 100644 --- a/src/runmode-netmap.c +++ b/src/runmode-netmap.c @@ -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); + } } }