From e122f375ab2bcbf5a7e009f2adc6b56809bb0343 Mon Sep 17 00:00:00 2001 From: Jonathan Berrewaerts Date: Wed, 18 Mar 2026 16:11:00 +0100 Subject: [PATCH 1/2] Add pool callback --- apache2/msc_reqbody.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apache2/msc_reqbody.c b/apache2/msc_reqbody.c index e00a4fc3fb..2e08db88d1 100644 --- a/apache2/msc_reqbody.c +++ b/apache2/msc_reqbody.c @@ -94,7 +94,7 @@ apr_status_t modsecurity_request_body_start(modsec_rec *msr, char **error_msg) { * via malloc). */ apr_pool_create(&msr->msc_reqbody_mp, NULL); - + apr_pool_abort_set(apr_pool_abort_get(msr->mp), msr->msc_reqbody_mp); /* Initialise request body processors, if any. */ if (msr->msc_reqbody_processor != NULL) { From 6dd093cd1bb44030e18638300a1694a53aba869c Mon Sep 17 00:00:00 2001 From: Jonathan Berrewaerts Date: Wed, 29 Apr 2026 15:28:24 +0200 Subject: [PATCH 2/2] fix: handle memory pool creation failure in modsecurity_request_body_start Co-authored-by: Copilot --- apache2/msc_reqbody.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/apache2/msc_reqbody.c b/apache2/msc_reqbody.c index 2e08db88d1..757bb1ed84 100644 --- a/apache2/msc_reqbody.c +++ b/apache2/msc_reqbody.c @@ -86,6 +86,7 @@ apr_status_t modsecurity_request_body_start(modsec_rec *msr, char **error_msg) { assert(msr != NULL); assert(error_msg != NULL); *error_msg = NULL; + apr_status_t rc; msr->msc_reqbody_length = 0; msr->stream_input_length = 0; @@ -93,7 +94,13 @@ apr_status_t modsecurity_request_body_start(modsec_rec *msr, char **error_msg) { * to allocate structures from (not data, which is allocated * via malloc). */ - apr_pool_create(&msr->msc_reqbody_mp, NULL); + rc = apr_pool_create(&msr->msc_reqbody_mp, NULL); + if (rc != APR_SUCCESS) { + *error_msg = apr_psprintf(msr->mp, "Input filter: Failed to create memory pool for request body: %s", + get_apr_error(msr->mp, rc)); + return -1; + } + apr_pool_abort_set(apr_pool_abort_get(msr->mp), msr->msc_reqbody_mp); /* Initialise request body processors, if any. */