Skip to content

Commit ce4a2f0

Browse files
committed
Fixed bug #71559 Built-in HTTP server, we can downlaod file in web by bug
1 parent fece24f commit ce4a2f0

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

sapi/cli/php_cli_server.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2058,6 +2058,19 @@ static int php_cli_server_begin_send_static(php_cli_server *server, php_cli_serv
20582058
return php_cli_server_send_error_page(server, client, 400 TSRMLS_CC);
20592059
}
20602060

2061+
#ifdef PHP_WIN32
2062+
/* The win32 namespace will cut off trailing dots and spaces. Since the
2063+
VCWD functionality isn't used here, a sophisticated functionality
2064+
would have to be reimplemented to know ahead there are no files
2065+
with invalid names there. The simplest is just to forbid invalid
2066+
filenames, which is done here. */
2067+
if (client->request.path_translated &&
2068+
('.' == client->request.path_translated[client->request.path_translated_len-1] ||
2069+
' ' == client->request.path_translated[client->request.path_translated_len-1])) {
2070+
return php_cli_server_send_error_page(server, client, 500);
2071+
}
2072+
#endif
2073+
20612074
fd = client->request.path_translated ? open(client->request.path_translated, O_RDONLY): -1;
20622075
if (fd < 0) {
20632076
return php_cli_server_send_error_page(server, client, 404 TSRMLS_CC);

0 commit comments

Comments
 (0)