Skip to content

Commit 24e94a8

Browse files
committed
Allow requests with length equal to SecRequestBodyNoFilesLimit
1 parent 6c78df4 commit 24e94a8

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

apache2/msc_reqbody.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ apr_status_t modsecurity_request_body_store(modsec_rec *msr,
406406
}
407407

408408
/* Check that we are not over the request body no files limit. */
409-
if (msr->msc_reqbody_no_files_length >= (unsigned long) msr->txcfg->reqbody_no_files_limit) {
409+
if (msr->msc_reqbody_no_files_length > (unsigned long) msr->txcfg->reqbody_no_files_limit) {
410410
*error_msg = apr_psprintf(msr->mp, "Request body no files data length is larger than the "
411411
"configured limit (%ld).", msr->txcfg->reqbody_no_files_limit);
412412
if (msr->txcfg->debuglog_level >= 1) {
@@ -671,7 +671,7 @@ apr_status_t modsecurity_request_body_end(modsec_rec *msr, char **error_msg) {
671671

672672

673673
/* Check that we are not over the request body no files limit. */
674-
if (msr->msc_reqbody_no_files_length >= (unsigned long)msr->txcfg->reqbody_no_files_limit) {
674+
if (msr->msc_reqbody_no_files_length > (unsigned long)msr->txcfg->reqbody_no_files_limit) {
675675
*error_msg = apr_psprintf(msr->mp, "Request body no files data length is larger than the "
676676
"configured limit (%ld).", msr->txcfg->reqbody_no_files_limit);
677677
if (msr->txcfg->debuglog_level >= 1) {

tests/regression/config/10-request-directives.t

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,3 +750,42 @@
750750
),
751751
},
752752

753+
# SecRequestBodyNoFilesLimit
754+
{
755+
type => "config",
756+
comment => "SecRequestBodyNoFilesLimit - length is equal to limit",
757+
conf => q(
758+
SecRuleEngine On
759+
SecRequestBodyAccess On
760+
SecRequestBodyNoFilesLimit 16
761+
),
762+
match_response => {
763+
status => qr/^200$/,
764+
},
765+
request => new HTTP::Request(
766+
POST => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt",
767+
[
768+
"Content-Type" => "application/x-www-form-urlencoded",
769+
],
770+
"a=0123456789ABCD",
771+
),
772+
},
773+
{
774+
type => "config",
775+
comment => "SecRequestBodyNoFilesLimit - length is larger than limit",
776+
conf => q(
777+
SecRuleEngine On
778+
SecRequestBodyAccess On
779+
SecRequestBodyNoFilesLimit 16
780+
),
781+
match_response => {
782+
status => qr/^413$/,
783+
},
784+
request => new HTTP::Request(
785+
POST => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt",
786+
[
787+
"Content-Type" => "application/x-www-form-urlencoded",
788+
],
789+
"a=0123456789ABCDE",
790+
),
791+
},

0 commit comments

Comments
 (0)