Skip to content

Commit

Permalink
Prevent lookups on 0.0.0.0/8.
Browse files Browse the repository at this point in the history
  • Loading branch information
IPQualityScore committed Jul 15, 2024
1 parent 4d7c23a commit 36af2eb
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/IPQualityScore/DB/DBReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ public function Fetch($ip){
throw new FileReaderException("Attemtped to look up IPv6 using IPv4 database file. Aborting.");
}

if($this->ipv6 === false) {
//NOTE: this "magic number" is ip2long(0.255.255.255)
if(ip2long($ip) <= 16777215){
throw new Exception("Attempted to look up ip in 0.0.0.0/8 range. Aborting.");
}
}

$position = 0;
$previous = array();
$literal = $this->IP2Literal($ip);
Expand Down

0 comments on commit 36af2eb

Please sign in to comment.