AP_DECLARE(void) ap_custom_response(request_rec *r, int status, const char *string);
/**
- * Check if the current request is beyond the configured max. number of redirects
+ * Check if the current request is beyond the configured max. number of redirects or subrequests
* @param r The current request
* @return true (is exceeded) or false
- * @deffunc int ap_is_redirect_limit_exceeded(const request_rec *r)
+ * @deffunc int ap_is_recursion_limit_exceeded(const request_rec *r)
*/
-AP_DECLARE(int) ap_is_redirect_limit_exceeded(const request_rec *r);
-
-/**
- * Check if the current request is beyond the configured subreq nesting level
- * @param r The current request
- * @return true (is exceeded) or false
- * @deffunc int ap_is_subreq_limit_exceeded(const request_rec *r)
- */
-AP_DECLARE(int) ap_is_subreq_limit_exceeded(const request_rec *r);
+AP_DECLARE(int) ap_is_recursion_limit_exceeded(const request_rec *r);
/**
* Check for a definition from the server command line
return NULL;
}
-static void log_backtrace(const request_rec *top, const request_rec *r)
+static void log_backtrace(const request_rec *r)
{
- while (top) {
- ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
- "redirected from r->uri = %s",
- top->uri ? top->uri : "(unexpectedly NULL)");
+ const request_rec *top = r;
+
+ ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
+ "r->uri = %s", r->uri ? r->uri : "(unexpectedly NULL)");
+
+ while (top && (top->prev || top->main)) {
+ if (top->prev) {
+ top = top->prev;
+ ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
+ "redirected from r->uri = %s",
+ top->uri ? top->uri : "(unexpectedly NULL)");
+ }
if (!top->prev && top->main) {
top = top->main;
-
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
"subrequested from r->uri = %s",
top->uri ? top->uri : "(unexpectedly NULL)");
}
- else {
- top = top->prev;
- }
}
}
/*
* check whether redirect limit is reached
*/
-AP_DECLARE(int) ap_is_redirect_limit_exceeded(const request_rec *r)
+AP_DECLARE(int) ap_is_recursion_limit_exceeded(const request_rec *r)
{
core_server_config *conf = ap_get_module_config(r->server->module_config,
&core_module);
const request_rec *top = r;
- int redirects = 0;
- int limit = conf->redirect_limit
- ? conf->redirect_limit
- : AP_DEFAULT_MAX_INTERNAL_REDIRECTS;
-
- while (top->prev) {
- if (++redirects >= limit) {
- /* uuh, too much. */
- ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
- "Request exceeded the limit of %d internal redirects "
- "due to probable configuration error. Use "
- "'LimitInternalRecursion' to increase the limit if "
- "necessary. Use 'LogLevel debug' to get a "
- "backtrace.", limit);
+ int redirects = 0, subreqs = 0;
+ int rlimit = conf->redirect_limit
+ ? conf->redirect_limit
+ : AP_DEFAULT_MAX_INTERNAL_REDIRECTS;
+ int slimit = conf->subreq_limit
+ ? conf->subreq_limit
+ : AP_DEFAULT_MAX_SUBREQ_DEPTH;
+
+
+ while (top->prev || top->main) {
+ if (top->prev) {
+ if (++redirects >= rlimit) {
+ /* uuh, too much. */
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
+ "Request exceeded the limit of %d internal "
+ "redirects due to probable configuration error. "
+ "Use 'LimitInternalRecursion' to increase the "
+ "limit if necessary. Use 'LogLevel debug' to get "
+ "a backtrace.", rlimit);
- /* post backtrace */
- log_backtrace(r->prev, r);
+ /* post backtrace */
+ log_backtrace(r);
- /* return failure */
- return 1;
- }
+ /* return failure */
+ return 1;
+ }
- if (!top->prev && top->main) {
- top = top->main;
- }
- else {
top = top->prev;
}
- }
- /* number of redirects is ok */
- return 0;
-}
+ if (!top->prev && top->main) {
+ if (++subreqs >= slimit) {
+ /* uuh, too much. */
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
+ "Request exceeded the limit of %d subrequest "
+ "nesting levels due to probable confguration "
+ "error. Use 'LimitInternalRecursion' to increase "
+ "the limit if necessary. Use 'LogLevel debug' to "
+ "get a backtrace.", slimit);
-/*
- * check whether subrequest depth limit is reached
- */
-AP_DECLARE(int) ap_is_subreq_limit_exceeded(const request_rec *r)
-{
- core_server_config *conf = ap_get_module_config(r->server->module_config,
- &core_module);
- const request_rec *top = r;
- int subreqs = 0;
- int limit = conf->subreq_limit
- ? conf->subreq_limit
- : AP_DEFAULT_MAX_SUBREQ_DEPTH;
-
- while (top->main) {
- if (++subreqs >= limit) {
- /* uuh, too much. */
- ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
- "Request exceeded the limit of %d subrequest "
- "nesting levels due to probable confguration error. "
- "Use 'LimitInternalRecursion' to increase the limit "
- "if necessary. Use 'LogLevel debug' to get a "
- "backtrace.", limit);
+ /* post backtrace */
+ log_backtrace(r);
- /* post backtrace */
- log_backtrace(r->main, r);
+ /* return failure */
+ return 1;
+ }
- /* return failure */
- return 1;
+ top = top->main;
}
-
- top = top->main;
}
- /* number of subrequests is ok */
+ /* recursion state: ok */
return 0;
}