|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #76479 Inconsistent IPv6 handling
Submitted: 2018-06-14 20:13 UTC Modified: -
Avg. Score:3.3 ± 0.5
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: Vaughn dot Frick at Ashbec dot com Assigned:
Status: Open Package: Network related
PHP Version: 7.1.18 OS: Windows 10
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: Vaughn dot Frick at Ashbec dot com
New email:
PHP Version: OS:


 [2018-06-14 20:13 UTC] Vaughn dot Frick at Ashbec dot com
From manual page:
Actually PHP 7.1.14 (not a choice above)

$_SERVER['REMOTE_ADDR'] correctly returns an IPv6 address but it includes any zone ID's appended to the IPv6 address (%nn).  The zone ID is needed to identify the particular NIC on that host so I would like to keep this behavior.  However, if the IPv6 address including the zone ID is used with gethostbyaddr, it will fail as an invalid IPv6 address.  I would prefer not having to strip the zone ID off the address as I have below.  The two should be consistent.  My vote is to have gethostbyaddr recognize a valid zone ID and ignore it.

Test script:
$visit_IP = $_SERVER['REMOTE_ADDR'];
// Strip any zone ID's off the IP address or gethostbyaddr will fail
if (stristr($visit_IP, "%")) {$visit_IP = stristr($visit_IP, "%", TRUE);}
$visit_host = gethostbyaddr($visit_IP);


Add a Patch

Pull Requests

Add a Pull Request

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 17 02:01:30 2024 UTC