* check whether redirect limit is reached */
| 3998 | * check whether redirect limit is reached |
| 3999 | */ |
| 4000 | AP_DECLARE(int) ap_is_recursion_limit_exceeded(const request_rec *r) |
| 4001 | { |
| 4002 | core_server_config *conf = |
| 4003 | ap_get_core_module_config(r->server->module_config); |
| 4004 | const request_rec *top = r; |
| 4005 | int redirects = 0, subreqs = 0; |
| 4006 | int rlimit = conf->redirect_limit |
| 4007 | ? conf->redirect_limit |
| 4008 | : AP_DEFAULT_MAX_INTERNAL_REDIRECTS; |
| 4009 | int slimit = conf->subreq_limit |
| 4010 | ? conf->subreq_limit |
| 4011 | : AP_DEFAULT_MAX_SUBREQ_DEPTH; |
| 4012 | |
| 4013 | |
| 4014 | while (top->prev || top->main) { |
| 4015 | if (top->prev) { |
| 4016 | if (++redirects >= rlimit) { |
| 4017 | /* uuh, too much. */ |
| 4018 | ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00124) |
| 4019 | "Request exceeded the limit of %d internal " |
| 4020 | "redirects due to probable configuration error. " |
| 4021 | "Use 'LimitInternalRecursion' to increase the " |
| 4022 | "limit if necessary. Use 'LogLevel debug' to get " |
| 4023 | "a backtrace.", rlimit); |
| 4024 | |
| 4025 | /* post backtrace */ |
| 4026 | log_backtrace(r); |
| 4027 | |
| 4028 | /* return failure */ |
| 4029 | return 1; |
| 4030 | } |
| 4031 | |
| 4032 | top = top->prev; |
| 4033 | } |
| 4034 | |
| 4035 | if (!top->prev && top->main) { |
| 4036 | if (++subreqs >= slimit) { |
| 4037 | /* uuh, too much. */ |
| 4038 | ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00125) |
| 4039 | "Request exceeded the limit of %d subrequest " |
| 4040 | "nesting levels due to probable configuration " |
| 4041 | "error. Use 'LimitInternalRecursion' to increase " |
| 4042 | "the limit if necessary. Use 'LogLevel debug' to " |
| 4043 | "get a backtrace.", slimit); |
| 4044 | |
| 4045 | /* post backtrace */ |
| 4046 | log_backtrace(r); |
| 4047 | |
| 4048 | /* return failure */ |
| 4049 | return 1; |
| 4050 | } |
| 4051 | |
| 4052 | top = top->main; |
| 4053 | } |
| 4054 | } |
| 4055 | |
| 4056 | /* recursion state: ok */ |
| 4057 | return 0; |
no test coverage detected