diff --git a/src/IPQualityScore/DB/DBReader.php b/src/IPQualityScore/DB/DBReader.php index 39dd72f..4958669 100644 --- a/src/IPQualityScore/DB/DBReader.php +++ b/src/IPQualityScore/DB/DBReader.php @@ -45,6 +45,14 @@ public function Fetch($ip){ throw new FileReaderException("Attemtped to look up IPv6 using IPv4 database file. Aborting."); } + list(, $subnet, ) = explode('/', "0.0.0.0/8"); + $incomingIP = ip2long($ip); + if (ip2long($subnet) <= $incomingIP && $incomingIP <= ip2long('255.255.255.255')) { + // ip is in acceptable range + } else { + throw new Exception("Attempted to look up ip in 0.0.0.0/8 range. Aborting."); + } + $position = 0; $previous = array(); $literal = $this->IP2Literal($ip);