File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -633,10 +633,14 @@ static void sapi_cli_server_register_variables(zval *track_vars_array) /* {{{ */
633
633
char * tmp ;
634
634
if ((tmp = strrchr (client -> addr_str , ':' ))) {
635
635
char addr [64 ], port [8 ];
636
+ const char * addr_start = client -> addr_str , * addr_end = tmp ;
637
+ if (addr_start [0 ] == '[' ) addr_start ++ ;
638
+ if (addr_end [-1 ] == ']' ) addr_end -- ;
639
+
636
640
strncpy (port , tmp + 1 , 8 );
637
641
port [7 ] = '\0' ;
638
- strncpy (addr , client -> addr_str , tmp - client -> addr_str );
639
- addr [tmp - client -> addr_str ] = '\0' ;
642
+ strncpy (addr , addr_start , addr_end - addr_start );
643
+ addr [addr_end - addr_start ] = '\0' ;
640
644
sapi_cli_server_register_variable (track_vars_array , "REMOTE_ADDR" , addr );
641
645
sapi_cli_server_register_variable (track_vars_array , "REMOTE_PORT" , port );
642
646
} else {
You can’t perform that action at this time.
0 commit comments