#40301 [Opn->Csd]: ip-to-country.inc has a wrong RegExp to ignore RFC 1918 addresses
| From: | nlopess@php.net | Date: | Fri, 02 Feb 2007 14:35:08 +0000 |
| Subject: | #40301 [Opn->Csd]: ip-to-country.inc has a wrong RegExp to ignore RFC 1918 addresses | ||
| References: | 1 | Groups: | php.mirrors |
| Request: | Send a blank email to php-mirrors+get-34031@lists.php.net to get a copy of this message | ||
ID: 40301
Updated by: nlopess@php.net
Reported By: v1d4l0k4 at gmail dot com
-Status: Open
+Status: Closed
Bug Type: Website problem
Operating System: Irrelevant
PHP Version: Irrelevant
New Comment:
This bug has been fixed in CVS. Since the websites are not directly
updated from the CVS server, the fix might need some time to spread
across the globe to all mirror sites, including PHP.net itself.
Thank you for the report, and for helping us make PHP.net better.
Previous Comments:
------------------------------------------------------------------------
[2007-02-01 04:40:53] v1d4l0k4 at gmail dot com
Description:
------------
In agreement with the RFC 1918 document (page 4, item 3), the Internet
Assigned Numbers Authority (IANA) has reserved the following three
blocks of the IP address space for private internets:
10.0.0.0 - 10.255.255.255 (10/8 prefix)
172.16.0.0 - 172.31.255.255 (172.16/12 prefix)
192.168.0.0 - 192.168.255.255 (192.168/16 prefix)
Ok, until there it's good. :)
Main problem: The www.php.net/source.php?url=/include/ip-to-country.inc
include file used here has a wrong regular expression. The RegExp used
doesn't ignore 172.17.0.0-172.31.255.255 IP block, that they're
private.
Other problem: As well told smith99 on ip-to-country.com forums (topic:
http://ip-to-country.webhosting.info/node/view/43),
the RegExp also
doesn't ignore Unknown values of some proxies.
Reproduce code:
---------------
Line 207-210:
// Skip RFC 1918 IP's 10.0.0.0/8, 172.16.0.0/12 and
// 192.168.0.0/16 -- jim kill me later with my regexp
pattern
// below.
if (!eregi ("^(10|172\.16|192\.168)\.", $ips[$i])) {
Expected result:
----------------
Also ignore 172.17.0.0-172.31.255.255 IP block and Unknown values, with
something as this code:
// Skip RFC 1918 IP's 10.x.x.x/8, 172.16-31.x.x/12 and
// 192.168.x.x/16 -- jim kill me later with my regexp
pattern
// below.
if
(!preg_match("/^(unknown|10|172\.(1[6-9]|2[0-9]|3[0-1])|192\.168)\.*/",
$ips[$i])) {
Actual result:
--------------
172.17.0.0-172.31.255.255 IP block and Unknown values doesn't ignored.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=40301&edit=1