php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53150 127.0.0.1 is valid with FILTER_FLAG_NO_PRIV_RANGE/FILTER_FLAG_NO_RES_RANGE
Submitted: 2010-10-25 16:01 UTC Modified: 2010-12-12 19:36 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: mentalstring+phpnet at gmail dot com Assigned: iliaa (profile)
Status: Closed Package: Filter related
PHP Version: 5.3.3 OS: linux
Private report: No CVE-ID: None
 [2010-10-25 16:01 UTC] mentalstring+phpnet at gmail dot com
Description:
------------
The 127.0.0.1 IP address is considered to be valid even when filtering with either 
the FILTER_FLAG_NO_RES_RANGE and FILTER_FLAG_NO_PRIV_RANGE flags.

This might be related with bug #47435.

Test script:
---------------
var_dump(filter_var('127.0.0.1', FILTER_VALIDATE_IP)); // true
var_dump(filter_var("::1", FILTER_VALIDATE_IP)); // true

var_dump(filter_var('127.0.0.1', FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE)); // false
var_dump(filter_var('::1', FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE)); // false

var_dump(filter_var('127.0.0.1', FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE));
var_dump(filter_var('::1', FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE));


Expected result:
----------------
true
true
false
false
false
false

Actual result:
--------------
true
true
false
false
false
false

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-10-25 16:07 UTC] mentalstring+phpnet at gmail dot com
Apologies, entered the wrong output values.

Expected result:

string(9) "127.0.0.1"
string(3) "::1"
bool(false)
bool(false)
bool(false)
bool(false)




Actual result:

string(9) "127.0.0.1"
string(3) "::1"
string(9) "127.0.0.1"
string(3) "::1"
string(9) "127.0.0.1"
string(3) "::1"


The IP address 127.0.0.1 might be a special IP - not quite sure if it fits in 
the private range, or the reserved range. Or perhaps, there should be a special 
range for this special cases.
 [2010-12-12 19:36 UTC] iliaa@php.net
Automatic comment from SVN on behalf of iliaa
Revision: http://svn.php.net/viewvc/?view=revision&revision=306282
Log: Fixed bug #53150 (FILTER_FLAG_NO_RES_RANGE is missing some IP ranges)
 [2010-12-12 19:36 UTC] iliaa@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: iliaa
 [2010-12-12 19:36 UTC] iliaa@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 06 21:01:27 2024 UTC