Skip to content

Commit a7d1198

Browse files
committed
Fix segmentation fault in modsecurity_request_body_enable_partial_processing
1 parent 72045a4 commit a7d1198

2 files changed

Lines changed: 12 additions & 7 deletions

File tree

apache2/msc_reqbody.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,10 @@ apr_status_t modsecurity_request_body_store(modsec_rec *msr,
442442
*/
443443
void modsecurity_request_body_enable_partial_processing(modsec_rec *msr) {
444444
msr->reqbody_partial_processing_enabled = 1;
445-
if (strcmp(msr->msc_reqbody_processor, "MULTIPART") == 0) {
445+
if (msr->msc_reqbody_processor == NULL) {
446+
msr_log(msr, 9, "enable_partial_processing for none reqbody_processor");
447+
}
448+
else if (strcmp(msr->msc_reqbody_processor, "MULTIPART") == 0) {
446449
msr->mpd->allow_process_partial = 1;
447450
msr_log(msr, 4, "Multipart: Allow partial processing of request body");
448451
}

tests/regression/config/10-reqbody-limit-action-forcebodybuf.t

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@
136136
},
137137
{
138138
type => "config",
139-
comment => "SecRequestBodyLimitAction ProcessPartial (forcebodybuf, >Limit, <=NoFilesLimit) should be 200",
139+
comment => "SecRequestBodyLimitAction ProcessPartial (forcebodybuf, >Limit, <=NoFilesLimit)",
140140
conf => qq(
141141
SecRuleEngine On
142142
SecDebugLog $ENV{DEBUG_LOG}
@@ -148,10 +148,11 @@
148148
SecRule REQUEST_URI "/test.txt" "id:500219,phase:1,t:none,pass,ctl:forceRequestBodyVariable=On"
149149
),
150150
match_log => {
151-
error => [ qr/exit signal Segmentation fault \(11\), possible coredump in/, 1 ],
151+
error => [ qr/ModSecurity: Request body \(Content-Length\) is larger than the configured limit \(16384\)\./, 1 ],
152+
debug => [ qr/enable_partial_processing for none reqbody_processor/, 1 ],
152153
},
153154
match_response => {
154-
status => qr/^500$/,
155+
status => qr/^200$/,
155156
},
156157
request => new HTTP::Request(
157158
POST => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt",
@@ -164,7 +165,7 @@
164165
},
165166
{
166167
type => "config",
167-
comment => "SecRequestBodyLimitAction ProcessPartial (forcebodybuf, >Limit, >NoFilesLimit) should be 200",
168+
comment => "SecRequestBodyLimitAction ProcessPartial (forcebodybuf, >Limit, >NoFilesLimit)",
168169
conf => qq(
169170
SecRuleEngine On
170171
SecDebugLog $ENV{DEBUG_LOG}
@@ -176,10 +177,11 @@
176177
SecRule REQUEST_URI "/test.txt" "id:500219,phase:1,t:none,pass,ctl:forceRequestBodyVariable=On"
177178
),
178179
match_log => {
179-
error => [ qr/exit signal Segmentation fault \(11\), possible coredump in/, 1 ],
180+
error => [ qr/ModSecurity: Request body \(Content-Length\) is larger than the configured limit \(32768\)\./, 1 ],
181+
debug => [ qr/enable_partial_processing for none reqbody_processor/, 1 ],
180182
},
181183
match_response => {
182-
status => qr/^500$/,
184+
status => qr/^200$/,
183185
},
184186
request => new HTTP::Request(
185187
POST => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt",

0 commit comments

Comments
 (0)