]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect/iponly: fix parsing of '0' valued netmask
authorVictor Julien <victor@inliniac.net>
Sat, 11 Apr 2020 11:54:00 +0000 (13:54 +0200)
committerVictor Julien <victor@inliniac.net>
Mon, 13 Apr 2020 08:41:11 +0000 (10:41 +0200)
src/detect-engine-iponly.c

index e3d8b2155205889c496e0f44f5162f4019d5f2bc..dfedd3f9e5e7ac78cfae7ad8fcce448d750a34d6 100644 (file)
@@ -178,12 +178,14 @@ static int IPOnlyCIDRItemParseSingle(IPOnlyCIDRItem *dd, const char *str)
 
                 netmask = in.s_addr;
 
-                /* Extract cidr netmask */
-                while ((0x01 & netmask) == 0) {
-                    dd->netmask++;
-                    netmask = netmask >> 1;
+                if (netmask != 0) {
+                    /* Extract cidr netmask */
+                    while ((0x01 & netmask) == 0) {
+                        dd->netmask++;
+                        netmask = netmask >> 1;
+                    }
+                    dd->netmask = 32 - dd->netmask;
                 }
-                dd->netmask = 32 - dd->netmask;
             }
 
             r = inet_pton(AF_INET, ip, &in);