php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #61910
Patch php-cgi-disable-argv revision 2012-05-06 00:14 UTC by neweracracker at gmail dot com
Patch CVE-2012-1823.patch revision 2012-05-05 20:59 UTC by tyukish at parallels dot com
Patch cgi.diff-fix-check.patch revision 2012-05-04 01:08 UTC by erik at pizzadoos dot com
Patch cgi.diff revision 2012-05-02 18:45 UTC by rasmus@php.net

Patch cgi.diff-fix-check.patch for CGI/CLI related Bug #61910

Patch version 2012-05-04 01:08 UTC

Return to Bug #61910 | Download this patch
This patch is obsolete

Obsoleted by patches:

This patch renders other patches obsolete

Obsolete patches:

Patch Revisions:

Developer: erik@pizzadoos.com

diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c
index d9c3181..5c1c55e 100644
--- a/sapi/cgi/cgi_main.c
+++ b/sapi/cgi/cgi_main.c
@@ -70,6 +70,7 @@
 #include "php_main.h"
 #include "fopen_wrappers.h"
 #include "ext/standard/php_standard.h"
+#include "ext/standard/url.h"
 
 #ifdef PHP_WIN32
 # include <io.h>
@@ -1753,6 +1754,9 @@ int main(int argc, char *argv[])
 #ifndef PHP_WIN32
 	int status = 0;
 #endif
+	char *query_string;
+	char *decoded_query_string;
+	int skip_getopt = 0;
 
 #if 0 && defined(PHP_DEBUG)
 	/* IIS is always making things more difficult.  This allows
@@ -1803,7 +1807,16 @@ int main(int argc, char *argv[])
 		}
 	}
 
-	while ((c = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 0, 2)) != -1) {
+	if(query_string = getenv("QUERY_STRING")) {
+		decoded_query_string = strdup(query_string);
+		php_url_decode(decoded_query_string, strlen(decoded_query_string));
+		if(*decoded_query_string == '-' && strchr(query_string, '=') == NULL) {
+			skip_getopt = 1;
+		}
+		free(decoded_query_string);
+	}
+
+	while (!skip_getopt && (c = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 0, 2)) != -1) {
 		switch (c) {
 			case 'c':
 				if (cgi_sapi_module.php_ini_path_override) {
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 05:01:29 2024 UTC