From: Michael Orlitzky Date: Wed, 28 Jul 2010 18:07:36 +0000 (-0400) Subject: Fixed the maskbits parsing for invalid CIDRs. X-Git-Tag: 0.0.1~22 X-Git-Url: http://gitweb.michael.orlitzky.com/?p=hath.git;a=commitdiff_plain;h=e061c778a9234bd4e4ed2b6fe43422cbedda7de0 Fixed the maskbits parsing for invalid CIDRs. --- diff --git a/src/Cidr.hs b/src/Cidr.hs index 8fc014f..f13c4f3 100644 --- a/src/Cidr.hs +++ b/src/Cidr.hs @@ -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