php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #55107
Patch 5.4-fix revision 2011-07-19 17:29 UTC by fa@php.net

Patch 5.4-fix for Built-in web server Bug #55107

Patch version 2011-07-19 17:29 UTC

Return to Bug #55107 | Download this patch
Patch Revisions:

Developer: fa@php.net

--- sapi/cli/php_cli_server.c.orig	2011-07-19 19:25:07.000000000 +0200
+++ sapi/cli/php_cli_server.c	2011-07-19 19:24:54.000000000 +0200
@@ -242,8 +242,9 @@
 };
 
 static php_cli_server_http_reponse_status_code_pair template_map[] = {
+	{ 400, "<h1 class=\"h\">%s</h1><p>Bad Request.</p>" },
 	{ 404, "<h1 class=\"h\">%s</h1><p>The requested resource %s was not found on this server.</p>" },
-	{ 500, "<h1 class=\"h\">%s</h1><p>The server is temporality unavaiable.</p>" }
+	{ 500, "<h1 class=\"h\">%s</h1><p>The server is temporarily unavailable.</p>" }
 };
 
 static php_cli_server_ext_mime_type_pair mime_type_map[] = {
@@ -1735,6 +1736,14 @@
 	SG(server_context) = client;
 	status = php_cli_server_dispatch_router(server, client TSRMLS_CC);
 
+	/* check for null bytes in the url, bug #55107 */
+	if (strlen(client->request.vpath) != client->request.vpath_len) {
+		if (SUCCESS != php_cli_server_send_error_page(server, client, 400 TSRMLS_CC)) {
+			goto fail;
+		}
+		SG(server_context) = 0;
+		return SUCCESS;
+	}
 	if (status < 0) {
 		goto fail;
 	} else if (status > 0) {
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 19:01:28 2024 UTC