@@ -242,6 +242,7 @@ static php_cli_server_http_reponse_status_code_pair status_map[] = {
242
242
};
243
243
244
244
static php_cli_server_http_reponse_status_code_pair template_map [] = {
245
+ { 400 , "<h1 class=\"h\">%s</h1><p>Your browser sent a request that this server could not understand.</p>" },
245
246
{ 404 , "<h1 class=\"h\">%s</h1><p>The requested resource %s was not found on this server.</p>" },
246
247
{ 500 , "<h1 class=\"h\">%s</h1><p>The server is temporality unavaiable.</p>" }
247
248
};
@@ -1600,6 +1601,11 @@ static int php_cli_server_dispatch_script(php_cli_server *server, php_cli_server
1600
1601
destroy_request_info (& SG (request_info ));
1601
1602
return FAILURE ;
1602
1603
}
1604
+ if (strlen (client -> request .path_translated ) != client -> request .path_translated_len ) {
1605
+ /* can't handle paths that contain nul bytes */
1606
+ destroy_request_info (& SG (request_info ));
1607
+ return php_cli_server_send_error_page (server , client , 400 TSRMLS_CC );
1608
+ }
1603
1609
{
1604
1610
zend_file_handle zfd ;
1605
1611
zfd .type = ZEND_HANDLE_FILENAME ;
@@ -1625,6 +1631,11 @@ static int php_cli_server_begin_send_static(php_cli_server *server, php_cli_serv
1625
1631
int fd ;
1626
1632
int status = 200 ;
1627
1633
1634
+ if (client -> request .path_translated && strlen (client -> request .path_translated ) != client -> request .path_translated_len ) {
1635
+ /* can't handle paths that contain nul bytes */
1636
+ return php_cli_server_send_error_page (server , client , 400 TSRMLS_CC );
1637
+ }
1638
+
1628
1639
fd = client -> request .path_translated ? open (client -> request .path_translated , O_RDONLY ): -1 ;
1629
1640
if (fd < 0 ) {
1630
1641
char * errstr = get_last_error ();
0 commit comments