Make ip comparison binary safe

develop
Steve Allison 2013-02-21 12:39:10 +00:00
parent 94c87c5f89
commit 4c65639b2b
1 changed files with 2 additions and 1 deletions

View File

@ -41,7 +41,8 @@ class defense extends rcube_plugin {
*/ */
private function isIPinArray($ip, $array) { private function isIPinArray($ip, $array) {
foreach ($array as $value) { foreach ($array as $value) {
if ((strpos($value, '/') === false) && ($ip == $value)) { return true; } // If no slash '/' then its not a CIDR address and we can just string match
if ((strpos($value, '/') === false) && (strcmp($ip, $value) == 0)) { return true; }
if ($this->isIPv4inCIDR($ip, $value)) { return true; } if ($this->isIPv4inCIDR($ip, $value)) { return true; }
} }
return false; return false;