Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit16c2fcc

Browse files
committed
Ensure memory preallocation for streaming is bounded by SecRequestBodyLimit
1 parent940e2b6 commit16c2fcc

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

‎apache2/msc_reqbody.c‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,8 @@ apr_status_t modsecurity_request_body_to_stream(modsec_rec *msr, const char *buf
434434
if (msr->stream_input_data==NULL) {
435435
// Is the request body length is known beforehand? (requests that are not Transfer-Encoding: chunked)
436436
if (msr->request_content_length>0) {
437-
allocate_length=msr->request_content_length;
437+
// Use min of Content-Length and SecRequestBodyLimit
438+
allocate_length=min(msr->request_content_length,msr->txcfg->reqbody_limit);
438439
}
439440
else {
440441
// We don't know how this request is going to be, so hope for just buflen to begin with (requests that are Transfer-Encoding: chunked)
@@ -472,6 +473,9 @@ apr_status_t modsecurity_request_body_to_stream(modsec_rec *msr, const char *buf
472473
"Unable to reallocate memory to hold request body on stream. Asked for %"APR_SIZE_T_FMT" bytes.",
473474
allocate_length);
474475
free(msr->stream_input_data);
476+
msr->stream_input_data=NULL;
477+
msr->stream_input_length=0;
478+
msr->stream_input_allocated_length=0;
475479
return-1;
476480
}
477481
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp