| 461 | |
| 462 | |
| 463 | static apr_status_t default_build_command(const char **cmd, const char ***argv, |
| 464 | request_rec *r, apr_pool_t *p, |
| 465 | cgi_exec_info_t *e_info) |
| 466 | { |
| 467 | int numwords, x, idx; |
| 468 | char *w; |
| 469 | const char *args = NULL; |
| 470 | |
| 471 | if (e_info->process_cgi) { |
| 472 | *cmd = r->filename; |
| 473 | /* Do not process r->args if they contain an '=' assignment |
| 474 | */ |
| 475 | if (r->args && r->args[0] && !ap_strchr_c(r->args, '=')) { |
| 476 | args = r->args; |
| 477 | } |
| 478 | } |
| 479 | |
| 480 | if (!args) { |
| 481 | numwords = 1; |
| 482 | } |
| 483 | else { |
| 484 | /* count the number of keywords */ |
| 485 | for (x = 0, numwords = 2; args[x]; x++) { |
| 486 | if (args[x] == '+') { |
| 487 | ++numwords; |
| 488 | } |
| 489 | } |
| 490 | } |
| 491 | /* Everything is - 1 to account for the first parameter |
| 492 | * which is the program name. |
| 493 | */ |
| 494 | if (numwords > APACHE_ARG_MAX - 1) { |
| 495 | numwords = APACHE_ARG_MAX - 1; /* Truncate args to prevent overrun */ |
| 496 | } |
| 497 | *argv = apr_palloc(p, (numwords + 2) * sizeof(char *)); |
| 498 | (*argv)[0] = *cmd; |
| 499 | for (x = 1, idx = 1; x < numwords; x++) { |
| 500 | w = ap_getword_nulls(p, &args, '+'); |
| 501 | ap_unescape_url(w); |
| 502 | (*argv)[idx++] = ap_escape_shell_cmd(p, w); |
| 503 | } |
| 504 | (*argv)[idx] = NULL; |
| 505 | |
| 506 | return APR_SUCCESS; |
| 507 | } |
| 508 | |
| 509 | static int cgi_handler(request_rec *r) |
| 510 | { |
nothing calls this directly
no test coverage detected