Skip to content

Commit

Permalink
Fixed #74699 - Missing range for FILTER_FLAG_NO_RES_RANGE
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnester committed Jun 7, 2017
1 parent c39a10b commit 4a0172c
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions ext/filter/logical_filters.c
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,7 @@ void php_filter_validate_ip(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
if (flags & FILTER_FLAG_NO_RES_RANGE) {
if (
(ip[0] == 0) ||
(ip[0] == 224 && ip[1] == 0 && ip[2] == 0) ||
(ip[0] >= 240) ||
(ip[0] == 127) ||
(ip[0] == 169 && ip[1] == 254)
Expand Down
37 changes: 37 additions & 0 deletions ext/filter/tests/bug74699.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
--TEST--
Bug #74699 (Missing range for FILTER_FLAG_NO_RES_RANGE)
--SKIPIF--
<?php
if (!extension_loaded('filter')) die('skip filter extension not available');
?>
--FILE--
<?php
$return = filter_var("223.255.255.255", FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE);
var_dump($return);

$return = filter_var("224.0.0.0", FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE);
var_dump($return);

$return = filter_var("224.0.0.2", FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE);
var_dump($return);

$return = filter_var("224.0.0.255", FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE);
var_dump($return);

$return = filter_var("224.0.1.0", FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE);
var_dump($return);

$return = filter_var("224.1.0.0", FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE);
var_dump($return);

$return = filter_var("225.0.0.0", FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE);
var_dump($return);
?>
--EXPECT--
string(15) "223.255.255.255"
bool(false)
bool(false)
bool(false)
string(9) "224.0.1.0"
string(9) "224.1.0.0"
string(9) "225.0.0.0"

0 comments on commit 4a0172c

Please sign in to comment.