MCPcopy Create free account
hub / github.com/apache/httpd / ap_limit_section

Function ap_limit_section

server/core.c:2368–2438  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2366}
2367
2368AP_CORE_DECLARE_NONSTD(const char *) ap_limit_section(cmd_parms *cmd,
2369 void *dummy,
2370 const char *arg)
2371{
2372 const char *endp = ap_strrchr_c(arg, '>');
2373 const char *limited_methods;
2374 void *tog = cmd->cmd->cmd_data;
2375 apr_int64_t limited = 0;
2376 apr_int64_t old_limited = cmd->limited;
2377 const char *errmsg;
2378
2379 if (endp == NULL) {
2380 return unclosed_directive(cmd);
2381 }
2382
2383 limited_methods = apr_pstrmemdup(cmd->temp_pool, arg, endp - arg);
2384
2385 if (!limited_methods[0]) {
2386 return missing_container_arg(cmd);
2387 }
2388
2389 while (limited_methods[0]) {
2390 char *method = ap_getword_conf(cmd->temp_pool, &limited_methods);
2391 int methnum;
2392
2393 /* check for builtin or module registered method number */
2394 methnum = ap_method_number_of(method);
2395
2396 if (methnum == M_TRACE && !tog) {
2397 return "TRACE cannot be controlled by <Limit>, see TraceEnable";
2398 }
2399 else if (methnum == M_INVALID) {
2400 /* method has not been registered yet, but resource restriction
2401 * is always checked before method handling, so register it.
2402 */
2403 if (cmd->pool == cmd->temp_pool) {
2404 /* In .htaccess, we can't globally register new methods. */
2405 return apr_psprintf(cmd->pool, "Could not register method '%s' "
2406 "for %s from .htaccess configuration",
2407 method, cmd->cmd->name);
2408 }
2409 methnum = ap_method_register(cmd->pool,
2410 apr_pstrdup(cmd->pool, method));
2411 }
2412
2413 limited |= (AP_METHOD_BIT << methnum);
2414 }
2415
2416 /* Killing two features with one function,
2417 * if (tog == NULL) <Limit>, else <LimitExcept>
2418 */
2419 limited = tog ? ~limited : limited;
2420
2421 if (!(old_limited & limited)) {
2422 return apr_pstrcat(cmd->pool, cmd->cmd->name,
2423 "> directive excludes all methods", NULL);
2424 }
2425 else if ((old_limited & limited) == old_limited) {

Callers

nothing calls this directly

Calls 7

ap_strrchr_cFunction · 0.85
unclosed_directiveFunction · 0.85
missing_container_argFunction · 0.85
ap_getword_confFunction · 0.85
ap_method_number_ofFunction · 0.85
ap_method_registerFunction · 0.85
ap_walk_configFunction · 0.85

Tested by

no test coverage detected