8000 improve fix for CVE-2012-1823 · php/php-src@fc3ba05 · GitHub
[go: up one dir, main page]

Skip to content

Commit fc3ba05

Browse files
committed
improve fix for CVE-2012-1823
1 parent 64170aa commit fc3ba05

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

sapi/cgi/cgi_main.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1806,10 +1806,15 @@ int main(int argc, char *argv[])
18061806
}
18071807
}
18081808

1809-
if(query_string = getenv("QUERY_STRING")) {
1809+
if((query_string = getenv("QUERY_STRING")) != NULL && strchr(query_string, '=') == NULL) {
1810+
/* we've got query string that has no = - apache CGI will pass it to command line */
1811+
unsigned char *p;
18101812
decoded_query_string = strdup(query_string);
18111813
php_url_decode(decoded_query_string, strlen(decoded_query_string));
1812-
if(*decoded_query_string == '-' && strchr(decoded_query_string, '=') == NULL) {
1814+
for (p = decoded_query_string; *p && *p <= ' '; p++) {
1815+
/* skip all leading spaces */
1816+
}
1817+
if(*p == '-') {
18131818
skip_getopt = 1;
18141819
}
18151820
free(decoded_query_string);
@@ -2073,7 +2078,7 @@ consult the installation file that came with this distribution, or visit \n\
20732078
}
20742079

20752080
zend_first_try {
2076-
while ((c = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 1, 2)) != -1) {
2081+
while (!skip_getopt && (c = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 1, 2)) != -1) {
20772082
switch (c) {
20782083
case 'T':
20792084
benchmark = 1;

0 commit comments

Comments
 (0)
0