diff --git a/apache2/mod_security2.c b/apache2/mod_security2.c index 75e24c07..4b478fe2 100644 --- a/apache2/mod_security2.c +++ b/apache2/mod_security2.c @@ -570,19 +570,21 @@ static int hook_request_early(request_rec *r) { return DECLINED; } - /* Check request body limit (should only trigger on non-chunked requests). */ - if (msr->request_content_length > msr->txcfg->reqbody_limit) { - msr_log(msr, 1, "Request body is larger than the " - "configured limit (%ld).", msr->txcfg->reqbody_limit); - return HTTP_REQUEST_ENTITY_TOO_LARGE; - } - /* Process phase REQUEST_HEADERS */ rc = DECLINED; if (modsecurity_process_phase(msr, PHASE_REQUEST_HEADERS) > 0) { rc = perform_interception(msr); } + if ((msr->txcfg->is_enabled != MODSEC_DISABLED) && (rc == DECLINED)) { + /* Check request body limit (non-chunked requests only). */ + if (msr->request_content_length > msr->txcfg->reqbody_limit) { + msr_log(msr, 1, "Request body (Content-Length) is larger than the " + "configured limit (%ld).", msr->txcfg->reqbody_limit); + return HTTP_REQUEST_ENTITY_TOO_LARGE; + } + } + return rc; }