This routine is called to create the argument list to be passed * to the CGI script. When suexec is enabled, the suexec path, user, and * group are the first three arguments to be passed; if not, all three * must be NULL. The query info is split into separate arguments, where * "+" is the separator between keyword arguments. * * Do not process the args if they containing an '=' assignment.
| 232 | * Do not process the args if they containing an '=' assignment. |
| 233 | */ |
| 234 | static char **create_argv(apr_pool_t *p, char *path, char *user, char *group, |
| 235 | char *av0, const char *args) |
| 236 | { |
| 237 | int x, numwords; |
| 238 | char **av; |
| 239 | char *w; |
| 240 | int idx = 0; |
| 241 | |
| 242 | if (!args || !(*args) || ap_strchr_c(args, '=')) { |
| 243 | numwords = 0; |
| 244 | } |
| 245 | else { |
| 246 | /* count the number of keywords */ |
| 247 | |
| 248 | for (x = 0, numwords = 1; args[x]; x++) { |
| 249 | if (args[x] == '+') { |
| 250 | ++numwords; |
| 251 | } |
| 252 | } |
| 253 | } |
| 254 | |
| 255 | if (numwords > APACHE_ARG_MAX - 5) { |
| 256 | numwords = APACHE_ARG_MAX - 5; /* Truncate args to prevent overrun */ |
| 257 | } |
| 258 | av = (char **) apr_pcalloc(p, (numwords + 5) * sizeof(char *)); |
| 259 | |
| 260 | if (path) { |
| 261 | av[idx++] = path; |
| 262 | } |
| 263 | if (user) { |
| 264 | av[idx++] = user; |
| 265 | } |
| 266 | if (group) { |
| 267 | av[idx++] = group; |
| 268 | } |
| 269 | |
| 270 | av[idx++] = apr_pstrdup(p, av0); |
| 271 | |
| 272 | for (x = 1; x <= numwords; x++) { |
| 273 | w = ap_getword_nulls(p, &args, '+'); |
| 274 | ap_unescape_url(w); |
| 275 | av[idx++] = ap_escape_shell_cmd(p, w); |
| 276 | } |
| 277 | av[idx] = NULL; |
| 278 | return av; |
| 279 | } |
| 280 | |
| 281 | #if APR_HAS_OTHER_CHILD |
| 282 | static void cgid_maint(int reason, void *data, apr_wait_t status) |
no test coverage detected