php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77722 Incorrect IP set to $_SERVER['REMOTE_ADDR'] on the localhost
Submitted: 2019-03-10 20:34 UTC Modified: 2019-03-12 08:41 UTC
From: josef dot sabl at gmail dot com Assigned: nikic (profile)
Status: Closed Package: Built-in web server
PHP Version: 7.3.3 OS: Windows
Private report: No CVE-ID: None
 [2019-03-10 20:34 UTC] josef dot sabl at gmail dot com
Description:
------------
If run as `php.exe -S localhost:88` the `$_SERVER['REMOTE_ADDR'] === '[::1]'` with the ::1 enclosed in brackets which is invalid and doesn't work with `inet_pton`

More info here:
https://github.com/nette/http/issues/152


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-03-11 11:37 UTC] cmb@php.net
-Status: Open +Status: Verified
 [2019-03-11 11:37 UTC] cmb@php.net
I can confirm the erroneous behavior.  It has been introduced with
commit 9501304[1].

[1] <http://git.php.net/?p=php-src.git;a=commit;h=95013042bf85ce1f52e476c5cc301faa97f52a72>
 [2019-03-11 22:36 UTC] kalle@php.net
-Status: Verified +Status: Assigned -Assigned To: +Assigned To: nikic
 [2019-03-11 22:36 UTC] kalle@php.net
Nikita, can you clarify this behaviour as the original committer of this change? And re-classify it as a doc bug if indeed so
 [2019-03-12 08:41 UTC] nikic@php.net
@kalle: The change is correct, but interacts incorrectly with the CLI server code in https://github.com/php/php-src/blob/623911f993f39ebbe75abe2771fc89faf6b15b9b/sapi/cli/php_cli_server.c#L634, which tries to extract the address simply by taking everything before ":". For IPv6 it additionally needs to strip the brackets.
 [2019-03-12 08:58 UTC] nikic@php.net
Automatic comment on behalf of nikita.ppv@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=a7739be22f8b376c58d666caa4479005e14bc2fa
Log: Fixed bug #77722
 [2019-03-12 08:58 UTC] nikic@php.net
-Status: Assigned +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 08:01:29 2024 UTC