]> 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)
committerJeff Lucovsky <jeff@lucovsky.org>
Thu, 16 Apr 2020 15:42:28 +0000 (11:42 -0400)
(cherry picked from commit 4d50eb1647709c9f2b8809f91b2af67be99ce4ab)

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);