php.net |  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: -
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.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
Have you experienced this issue?
Rate the importance of this bug to you:

 [2018-06-14 20:13 UTC] Vaughn dot Frick at Ashbec dot com
Description:
------------
---
From manual page: http://www.php.net/function.gethostbyaddr
---
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);


Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sun Dec 08 00:01:26 2019 UTC