helly Wed Feb 11 17:00:39 2004 EDT Modified files: (Branch: PHP_4_3) /php-src/sapi/cgi cgi_main.c /php-src/sapi/cli php_cli.c /php-src NEWS Log: MFH: Bug #27104 CLI/CGI SAPI module variable name conflict
http://cvs.php.net/diff.php/php-src/sapi/cgi/cgi_main.c?r1=1.190.2.57&r2=1.190.2.58&ty=u Index: php-src/sapi/cgi/cgi_main.c diff -u php-src/sapi/cgi/cgi_main.c:1.190.2.57 php-src/sapi/cgi/cgi_main.c:1.190.2.58 --- php-src/sapi/cgi/cgi_main.c:1.190.2.57 Wed Feb 11 09:52:34 2004 +++ php-src/sapi/cgi/cgi_main.c Wed Feb 11 17:00:34 2004 @@ -20,7 +20,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: cgi_main.c,v 1.190.2.57 2004/02/11 14:52:34 iliaa Exp $ */ +/* $Id: cgi_main.c,v 1.190.2.58 2004/02/11 22:00:34 helly Exp $ */ #include "php.h" #include "php_globals.h" @@ -119,8 +119,8 @@ #define PHP_MODE_LINT 4 #define PHP_MODE_STRIP 5 -static char *optarg = NULL; -static int optind = 1; +static char *php_optarg = NULL; +static int php_optind = 1; static const opt_struct OPTIONS[] = { {'a', 0, "interactive"}, @@ -960,8 +960,8 @@ /* temporary locals */ int behavior=PHP_MODE_STANDARD; int no_headers=0; - int orig_optind=optind; - char *orig_optarg=optarg; + int orig_optind=php_optind; + char *orig_optarg=php_optarg; char *script_file=NULL; zend_llist global_vars; int interactive=0; @@ -1039,10 +1039,10 @@ /* allow ini override for fastcgi */ #endif ) { - while ((c=php_getopt(argc, argv, OPTIONS, &optarg, &optind, 0))!=-1) { + while ((c=php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 0))!=-1) { switch (c) { case 'c': - cgi_sapi_module.php_ini_path_override = strdup(optarg); + cgi_sapi_module.php_ini_path_override = strdup(php_optarg); break; case 'n': cgi_sapi_module.php_ini_ignore = 1; @@ -1054,7 +1054,7 @@ server by accepting a bindpath parameter. */ case 'b': if (!fastcgi) { - bindpath = strdup(optarg); + bindpath = strdup(php_optarg); } break; #endif @@ -1062,8 +1062,8 @@ } } - optind = orig_optind; - optarg = orig_optarg; + php_optind = orig_optind; + php_optarg = orig_optarg; } #ifdef ZTS @@ -1269,7 +1269,7 @@ && !fastcgi #endif ) { - while ((c=php_getopt(argc, argv, OPTIONS, &optarg, &optind, 1))!=-1) { + while ((c=php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 1))!=-1) { switch (c) { case 'h': case '?': @@ -1283,8 +1283,8 @@ break; } } - optind = orig_optind; - optarg = orig_optarg; + php_optind = orig_optind; + php_optarg = orig_optarg; } #if PHP_FASTCGI @@ -1334,7 +1334,7 @@ exit(1); } - while ((c = php_getopt(argc, argv, OPTIONS, &optarg, &optind, 0)) != -1) { + while ((c = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 0)) != -1) { switch (c) { case 'a': /* interactive mode */ @@ -1346,7 +1346,7 @@ SG(options) |= SAPI_OPTION_NO_CHDIR; break; case 'd': /* define ini entries on command line */ - define_command_line_ini_entry(optarg); + define_command_line_ini_entry(php_optarg); break; case 'e': /* enable extended info output */ @@ -1354,16 +1354,16 @@ break; case 'f': /* parse file */ - script_file = estrdup(optarg); + script_file = estrdup(php_optarg); no_headers = 1; /* arguments after the file are considered script args */ - SG(request_info).argc = argc - (optind-1); - SG(request_info).argv = &argv[optind-1]; + SG(request_info).argc = argc - (php_optind-1); + SG(request_info).argv = &argv[php_optind-1]; break; case 'g': /* define global variables on command line */ { - char *arg = estrdup(optarg); + char *arg = estrdup(php_optarg); zend_llist_add_element(&global_vars, &arg); } @@ -1439,7 +1439,7 @@ break; case 'z': /* load extension file */ - zend_load_extension(optarg); + zend_load_extension(php_optarg); break; default: @@ -1460,12 +1460,12 @@ SG(request_info).no_headers = 1; } - if (!SG(request_info).path_translated && argc > optind) { + if (!SG(request_info).path_translated && argc > php_optind) { /* arguments after the file are considered script args */ - SG(request_info).argc = argc - optind; - SG(request_info).argv = &argv[optind]; + SG(request_info).argc = argc - php_optind; + SG(request_info).argv = &argv[php_optind]; /* file is on command line, but not in -f opt */ - SG(request_info).path_translated = estrdup(argv[optind++]); + SG(request_info).path_translated = estrdup(argv[php_optind++]); } /* all remaining arguments are part of the query string @@ -1477,15 +1477,15 @@ test.php "v1=test&v2=hello world!" test.php v1=test "v2=hello world!" */ - if (!SG(request_info).query_string && argc > optind) { + if (!SG(request_info).query_string && argc > php_optind) { len = 0; - for (i = optind; i < argc; i++) { + for (i = php_optind; i < argc; i++) { len += strlen(argv[i]) + 1; } s = malloc(len + 1); /* leak - but only for command line version, so ok */ *s = '\0'; /* we are pretending it came from the environment */ - for (i = optind, len = 0; i < argc; i++) { + for (i = php_optind, len = 0; i < argc; i++) { strcat(s, argv[i]); if (i < (argc - 1)) { strcat(s, PG(arg_separator).input); http://cvs.php.net/diff.php/php-src/sapi/cli/php_cli.c?r1=1.51.2.33&r2=1.51.2.34&ty=u Index: php-src/sapi/cli/php_cli.c diff -u php-src/sapi/cli/php_cli.c:1.51.2.33 php-src/sapi/cli/php_cli.c:1.51.2.34 --- php-src/sapi/cli/php_cli.c:1.51.2.33 Thu Feb 5 22:08:39 2004 +++ php-src/sapi/cli/php_cli.c Wed Feb 11 17:00:36 2004 @@ -91,8 +91,8 @@ #define PHP_MODE_STRIP 5 #define PHP_MODE_CLI_DIRECT 6 -static char *optarg = NULL; -static int optind = 1; +static char *php_optarg = NULL; +static int php_optind = 1; static const opt_struct OPTIONS[] = { {'a', 0, "interactive"}, @@ -500,8 +500,8 @@ zend_file_handle file_handle; /* temporary locals */ int behavior=PHP_MODE_STANDARD; - int orig_optind=optind; - char *orig_optarg=optarg; + int orig_optind=php_optind; + char *orig_optarg=php_optarg; char *arg_free=NULL, **arg_excp=&arg_free; char *script_file=NULL; zend_llist global_vars; @@ -549,18 +549,18 @@ #endif - while ((c = php_getopt(argc, argv, OPTIONS, &optarg, &optind, 0))!=-1) { + while ((c = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 0))!=-1) { switch (c) { case 'c': - cli_sapi_module.php_ini_path_override = strdup(optarg); + cli_sapi_module.php_ini_path_override = strdup(php_optarg); break; case 'n': cli_sapi_module.php_ini_ignore = 1; break; } } - optind = orig_optind; - optarg = orig_optarg; + php_optind = orig_optind; + php_optarg = orig_optarg; cli_sapi_module.executable_location = argv[0]; @@ -604,11 +604,11 @@ INI_HARDCODED("output_buffering", "0"); INI_HARDCODED("max_execution_time", "0"); - while ((c = php_getopt(argc, argv, OPTIONS, &optarg, &optind, 0)) != -1) { + while ((c = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 0)) != -1) { switch (c) { case 'd': /* define ini entries on command line */ - define_command_line_ini_entry(optarg); + define_command_line_ini_entry(php_optarg); break; case 'h': /* help & quit */ @@ -663,9 +663,9 @@ /* Set some CLI defaults */ SG(options) |= SAPI_OPTION_NO_CHDIR; - optind = orig_optind; - optarg = orig_optarg; - while ((c = php_getopt(argc, argv, OPTIONS, &optarg, &optind, 0)) != -1) { + php_optind = orig_optind; + php_optarg = orig_optarg; + while ((c = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 0)) != -1) { switch (c) { case 'a': /* interactive mode */ @@ -686,12 +686,12 @@ param_error = "Either execute direct code or use a file.\n"; break; } - script_file = optarg; + script_file = php_optarg; break; case 'g': /* define global variables on command line */ { - char *arg = estrdup(optarg); + char *arg = estrdup(php_optarg); zend_llist_add_element(&global_vars, &arg); } @@ -724,7 +724,7 @@ break; } behavior=PHP_MODE_CLI_DIRECT; - exec_direct=optarg; + exec_direct=php_optarg; break; case 's': /* generate highlighted HTML from source */ @@ -744,7 +744,7 @@ break; case 'z': /* load extension file */ - zend_load_extension(optarg); + zend_load_extension(php_optarg); break; case 'H': hide_argv = 1; @@ -764,9 +764,9 @@ CG(interactive) = interactive; /* only set script_file if not set already and not in direct mode and not at end of parameter list */ - if (argc > optind && !script_file && behavior!=PHP_MODE_CLI_DIRECT && strcmp(argv[optind-1],"--")) { - script_file=argv[optind]; - optind++; + if (argc > php_optind && !script_file && behavior!=PHP_MODE_CLI_DIRECT && strcmp(argv[php_optind-1],"--")) { + script_file=argv[php_optind]; + php_optind++; } if (script_file) { if (cli_seek_file_begin(&file_handle, script_file, &lineno TSRMLS_CC) != SUCCESS) { @@ -785,12 +785,12 @@ /* before registering argv to module exchange the *new* argv[0] */ /* we can achieve this without allocating more memory */ - SG(request_info).argc=argc-optind+1; - arg_excp = argv+optind-1; - arg_free = argv[optind-1]; + SG(request_info).argc=argc-php_optind+1; + arg_excp = argv+php_optind-1; + arg_free = argv[php_optind-1]; SG(request_info).path_translated = file_handle.filename; - argv[optind-1] = file_handle.filename; - SG(request_info).argv=argv+optind-1; + argv[php_optind-1] = file_handle.filename; + SG(request_info).argv=argv+php_optind-1; if (php_request_startup(TSRMLS_C)==FAILURE) { *arg_excp = arg_free; http://cvs.php.net/diff.php/php-src/NEWS?r1=1.1247.2.561&r2=1.1247.2.562&ty=u Index: php-src/NEWS diff -u php-src/NEWS:1.1247.2.561 php-src/NEWS:1.1247.2.562 --- php-src/NEWS:1.1247.2.561 Wed Feb 11 12:09:08 2004 +++ php-src/NEWS Wed Feb 11 17:00:38 2004 @@ -11,6 +11,7 @@ - Fixed bug #27171 (crash inside gmp_hamdist()). (Jani) - Fixed bug #27149 (broken CLOB support in oci8 extension). (Antony) - Fixed bug #27135 (Possible crash inside mb_strlen()). (Moriyoshi) +- Fixed bug #27104 (CLI/CGI SAPI module variable name conflict). (Marcus) - Fixed bug #27026 (Added "cgi.nph" php.ini option to allow forcing of the 'Status: 200' header that is not normally needed). (Ilia) - Fixed bug #26862 (ob_flush() followed by output_reset_rewrite_vars() may
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php