This commit is contained in:
Nikita Popov 2019-03-12 09:57:51 +01:00
parent 95c8f67a4c
commit a7739be22f
2 changed files with 10 additions and 2 deletions

4
NEWS
View File

@ -9,6 +9,10 @@ PHP NEWS
. Fixed bug #77345 (Stack Overflow caused by circular reference in garbage
collection). (Alexandru Patranescu, Nikita, Dmitry)
- CLI Server:
. Fixed bug #77722 (Incorrect IP set to $_SERVER['REMOTE_ADDR'] on the
localhost). (Nikita)
- Apache2Handler:
. Fixed bug #77648 (BOM in sapi/apache2handler/php_functions.c). (cmb)

View File

@ -637,10 +637,14 @@ static void sapi_cli_server_register_variables(zval *track_vars_array) /* {{{ */
char *tmp;
if ((tmp = strrchr(client->addr_str, ':'))) {
char addr[64], port[8];
const char *addr_start = client->addr_str, *addr_end = tmp;
if (addr_start[0] == '[') addr_start++;
if (addr_end[-1] == ']') addr_end--;
strncpy(port, tmp + 1, 8);
port[7] = '\0';
strncpy(addr, client->addr_str, tmp - client->addr_str);
addr[tmp - client->addr_str] = '\0';
strncpy(addr, addr_start, addr_end - addr_start);
addr[addr_end - addr_start] = '\0';
sapi_cli_server_register_variable(track_vars_array, "REMOTE_ADDR", addr);
sapi_cli_server_register_variable(track_vars_array, "REMOTE_PORT", port);
} else {