]> gitweb.michael.orlitzky.com - hath.git/blobdiff - src/Cidr.hs
Fixed the maskbits parsing for invalid CIDRs.
[hath.git] / src / Cidr.hs
index 8fc014f6cf5b062f8ae019d3b990c22a9604e9b8..f13c4f36e14104fe7d12cbb9a33715928a7a908b 100644 (file)
@@ -60,8 +60,11 @@ equivalent (Cidr addr1 mbits1) (Cidr addr2 mbits2) =
 -- Returns the mask portion of a CIDR address. That is, everything
 -- after the trailing slash.
 maskbits_from_cidr_string :: String -> Maskbits
-maskbits_from_cidr_string s =
-    maskbits_from_string ((splitWith (`elem` "/") s) !! 1)
+maskbits_from_cidr_string s
+    | length partlist == 2 = maskbits_from_string (partlist !! 1)
+    | otherwise = Maskbits.None
+      where
+        partlist = (splitWith (`elem` "/") s)
 
 
 -- Takes an IP address String in CIDR notation, and returns a list of