]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
util-ioctl: only get MTU when iface name is set
authorEric Leblond <eric@regit.org>
Thu, 10 Apr 2014 09:05:46 +0000 (11:05 +0200)
committerVictor Julien <victor@inliniac.net>
Mon, 14 Apr 2014 09:10:46 +0000 (11:10 +0200)
This patch fixes a warning message when suricata is started without
giving an interface name on the command line. The code was trying
to get the MTU even if pcap_dev was not set.

src/util-ioctl.c

index 4b2923a32b8cf51b6f4b95a244d45b6db102caba..0f144ec511ea7a5a33af6ee78e133016bed4ee40 100644 (file)
@@ -117,7 +117,12 @@ int GetIfaceMTU(char *pcap_dev)
 int GetIfaceMaxPacketSize(char *pcap_dev)
 {
     int ll_header = GetIfaceMaxHWHeaderLength(pcap_dev);
-    int mtu = GetIfaceMTU(pcap_dev);
+    int mtu = 0;
+
+    if ((pcap_dev == NULL) || strlen(pcap_dev) == 0)
+        return 0;
+
+    mtu = GetIfaceMTU(pcap_dev);
     switch (mtu) {
         case 0:
         case -1: