#40301 [NEW]: ip-to-country.inc has a wrong RegExp to ignore RFC 1918 addresses
| From: | v1d4l0k4 at gmail dot com | Date: | Thu, 01 Feb 2007 04:40:53 +0000 |
| Subject: | #40301 [NEW]: ip-to-country.inc has a wrong RegExp to ignore RFC 1918 addresses | ||
| Groups: | php.mirrors | ||
| Request: | Send a blank email to php-mirrors+get-33999@lists.php.net to get a copy of this message | ||
From: v1d4l0k4 at gmail dot com
Operating system: Irrelevant
PHP version: Irrelevant
PHP Bug Type: Website problem
Bug description: ip-to-country.inc has a wrong RegExp to ignore RFC 1918 addresses
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 bug report at http://bugs.php.net/?id=40301&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=40301&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=40301&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=40301&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=40301&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=40301&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=40301&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=40301&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=40301&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=40301&r=support
Expected behavior: http://bugs.php.net/fix.php?id=40301&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=40301&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=40301&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=40301&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=40301&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=40301&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=40301&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=40301&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=40301&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=40301&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=40301&r=mysqlcfg