rbb 99/12/16 11:58:08
Modified: src/modules/standard mod_include.c Log: After a few hours of thorough testing, this patch makes CGI's through SSI's work properly on Linux. We will be testing this change on Win32 momentarily, but because we are relying on APR for the dirty work, I have no fears. :-) Revision Changes Path 1.12 +16 -12 apache-2.0/src/modules/standard/mod_include.c Index: mod_include.c =================================================================== RCS file: /home/cvs/apache-2.0/src/modules/standard/mod_include.c,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- mod_include.c 1999/12/16 15:41:28 1.11 +++ mod_include.c 1999/12/16 19:58:00 1.12 @@ -780,7 +780,7 @@ const char *args = r->args; if (!args || !args[0] || strchr(args, '=')) { - *argv = NULL; + numwords = 1; } else { /* count the number of keywords */ @@ -789,18 +789,21 @@ ++numwords; } } - if (numwords > APACHE_ARG_MAX) { - numwords = APACHE_ARG_MAX; /* Truncate args to prevent overrun */ - } - *argv = (char **) ap_palloc(p, (numwords + 1) * sizeof(char *)); - - for (x = 1, idx = 0; x <= numwords; x++) { - w = ap_getword_nulls(p, &args, '+'); - ap_unescape_url(w); - (*argv)[idx++] = ap_escape_shell_cmd(p, w); - } - (*argv)[idx] = NULL; } + /* Everything is - 1 to account for the first parameter which is the + * program name. We didn't used to have to do this, but APR wants it. + */ + if (numwords > APACHE_ARG_MAX - 1) { + numwords = APACHE_ARG_MAX - 1; /* Truncate args to prevent overrun */ + } + *argv = (char **) ap_palloc(p, (numwords + 2) * sizeof(char *)); + + for (x = 1, idx = 1; x < numwords; x++) { + w = ap_getword_nulls(p, &args, '+'); + ap_unescape_url(w); + (*argv)[idx++] = ap_escape_shell_cmd(p, w); + } + (*argv)[idx] = NULL; return APR_SUCCESS; } @@ -861,6 +864,7 @@ } else { build_argv_list(&argv, r, r->pool); + argv[0] = ap_pstrdup(r->pool, s); rc = ap_create_process(&procnew, s, argv, ap_create_environment(r->pool, env), procattr, r->pool); if (rc != APR_SUCCESS) {