File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,10 @@ PHP NEWS
9
9
. Fixed bug #77345 (Stack Overflow caused by circular reference in garbage
10
10
collection). (Alexandru Patranescu, Nikita, Dmitry)
11
11
12
+ - CLI Server:
13
+ . Fixed bug #77722 (Incorrect IP set to $_SERVER['REMOTE_ADDR'] on the
14
+ localhost). (Nikita)
15
+
12
16
- Apache2Handler:
13
17
. Fixed bug #77648 (BOM in sapi/apache2handler/php_functions.c). (cmb)
14
18
Original file line number Diff line number Diff line change @@ -637,10 +637,14 @@ static void sapi_cli_server_register_variables(zval *track_vars_array) /* {{{ */
637
637
char * tmp ;
638
638
if ((tmp = strrchr (client -> addr_str , ':' ))) {
639
639
char addr [64 ], port [8 ];
640
+ const char * addr_start = client -> addr_str , * addr_end = tmp ;
641
+ if (addr_start [0 ] == '[' ) addr_start ++ ;
642
+ if (addr_end [-1 ] == ']' ) addr_end -- ;
643
+
640
644
strncpy (port , tmp + 1 , 8 );
641
645
port [7 ] = '\0' ;
642
- strncpy (addr , client -> addr_str , tmp - client -> addr_str );
643
- addr [tmp - client -> addr_str ] = '\0' ;
646
+ strncpy (addr , addr_start , addr_end - addr_start );
647
+ addr [addr_end - addr_start ] = '\0' ;
644
648
sapi_cli_server_register_variable (track_vars_array , "REMOTE_ADDR" , addr );
645
649
sapi_cli_server_register_variable (track_vars_array , "REMOTE_PORT" , port );
646
650
} else {
You can’t perform that action at this time.
0 commit comments