[dev] Fwd: ipv6 address bug in Token.php
Chuck Hagenbuch
chuck at horde.org
Sun Nov 21 20:21:07 PST 2004
Anyone able to replicate this and/or come up with a cleaner solution?
----- Forwarded message from tomas.hlavacek at elfove.cz -----
Date: Mon, 22 Nov 2004 05:19:09 +0100
From: Tomas Hlavacek <tomas.hlavacek at elfove.cz>
Reply-To: Tomas Hlavacek <tomas.hlavacek at elfove.cz>
Subject: ipv6 address bug in Token.php
To: chuck at horde.org
Hi,
I just want to inform you that I probably encoutered bug in CVS
version of Horde in file Token.php. It seems to be problem caused by
usage of IPv6 protocol which is not expected by Horde.
I have got Apache/2.0.52 (Gentoo/Linux) and I am using IPv6 to
access Horde. It is causing print of these messages into several parts
of Horde:
*Notice*: Undefined offset: 1 in */usr/lib/php/Horde/Token.php* on line *35*
*Notice*: Undefined offset: 2 in */usr/lib/php/Horde/Token.php* on line *35*
*Notice*: Undefined offset: 3 in */usr/lib/php/Horde/Token.php* on line *35
*I wrote some kind of silly workaround, which solves symptoms. I am
sending it to you only for information.
--- Token.php.old 2004-11-22 04:18:13.000000000 +0100
+++ Token.php 2004-11-22 05:14:56.458847976 +0100
@@ -31,8 +31,13 @@
function hexRemoteAddr()
{
- $addr = explode('.', $_SERVER['REMOTE_ADDR']);
- return sprintf('%02x%02x%02x%02x', $addr[0], $addr[1], $addr[2],
$addr[3]);
+
if(ereg("^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$",$_SERVER['REMOTE_ADDR'],$addr)){
+ return sprintf('%02x%02x%02x%02x', $addr[1], $addr[2], $addr[3],
$addr[4]);
+ }
+
if(ereg("^[0-9a-fA-F:]+([0-9a-fA-F]{1,4})[:]{1,2}([0-9a-fA-F]{1,4})[:]{1,2}([0-9a-fA-F]{1,4})[:]{1,2}([0-9a-fA-F]{1,4})$",$_SERVER['REMOTE_ADDR'],$addr)){
+ return sprintf('%02x%02x%02x%02x', $addr[1], $addr[2], $addr[3],
$addr[4]);
+ }
+ return sprintf('%02x%02x%02x%02x', 0, 0, 0, 0);
}
/**
Have a nice day
--
Tomas Hlavacek
Welcome this message in the name of allah!
----- End forwarded message -----
-chuck
--
"But she goes not abroad in search of monsters to destroy." - John Quincy Adams
More information about the dev
mailing list