diff options
| author | Andreas Fischer <bantu@phpbb.com> | 2011-04-19 13:53:09 +0200 |
|---|---|---|
| committer | Andreas Fischer <bantu@phpbb.com> | 2011-04-19 14:08:23 +0200 |
| commit | 5ca7121ed2f698963387f5f9fb7ffe16d3781447 (patch) | |
| tree | b90974b9fd80eab83b8e964f1435907b14f6aec0 /phpBB | |
| parent | bef2540d9ce3b429837c7e67c5f3f7f254aa1920 (diff) | |
| download | forums-5ca7121ed2f698963387f5f9fb7ffe16d3781447.tar forums-5ca7121ed2f698963387f5f9fb7ffe16d3781447.tar.gz forums-5ca7121ed2f698963387f5f9fb7ffe16d3781447.tar.bz2 forums-5ca7121ed2f698963387f5f9fb7ffe16d3781447.tar.xz forums-5ca7121ed2f698963387f5f9fb7ffe16d3781447.zip | |
[ticket/9802] Only check for IPv4-mapped address when address is IPv6.
PHPBB3-9802
Diffstat (limited to 'phpBB')
| -rw-r--r-- | phpBB/includes/session.php | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index f2aa47d84e..b2772696f1 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -278,26 +278,31 @@ class session foreach ($ips as $ip) { - // check IPv4 first, the IPv6 is hopefully only going to be used very seldomly - if (!preg_match(get_preg_expression('ipv4'), $ip) && !preg_match(get_preg_expression('ipv6'), $ip)) + if (preg_match(get_preg_expression('ipv4'), $ip)) { - // Just break - break; + $this->ip = $ip; } - - // Quick check for IPv4-mapped address in IPv6 - if (stripos($ip, '::ffff:') === 0) + else if (preg_match(get_preg_expression('ipv6'), $ip)) { - $ipv4 = substr($ip, 7); - - if (preg_match(get_preg_expression('ipv4'), $ipv4)) + // Quick check for IPv4-mapped address in IPv6 + if (stripos($ip, '::ffff:') === 0) { - $ip = $ipv4; + $ipv4 = substr($ip, 7); + + if (preg_match(get_preg_expression('ipv4'), $ipv4)) + { + $ip = $ipv4; + } } - } - // Use the last in chain - $this->ip = $ip; + $this->ip = $ip; + } + else + { + // We want to use the last valid address in the chain + // Leave foreach loop when address is invalid + break; + } } $this->load = false; |
