@@ -428,29 +428,29 @@ apr_status_t modsecurity_request_body_store(modsec_rec *msr,
428
428
}
429
429
430
430
apr_status_t modsecurity_request_body_to_stream (modsec_rec * msr , const char * buffer , int buflen , char * * error_msg ) {
431
- apr_size_t allocate ;
432
- char * allocated ;
431
+ apr_size_t allocate_length = 0 ;
432
+ char * allocated = NULL ;
433
433
434
434
if (msr -> stream_input_data == NULL ) {
435
435
// Is the request body length is known beforehand? (requests that are not Transfer-Encoding: chunked)
436
436
if (msr -> request_content_length > 0 ) {
437
- allocate = msr -> request_content_length ;
437
+ allocate_length = msr -> request_content_length ;
438
438
}
439
439
else {
440
440
// 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)
441
- allocate = buflen ;
441
+ allocate_length = buflen ;
442
442
}
443
443
444
- allocated = (char * ) calloc (allocate , sizeof (char ));
444
+ allocated = (char * ) calloc (allocate_length , sizeof (char ));
445
445
if (allocated ) {
446
446
msr -> stream_input_data = allocated ;
447
- msr -> stream_input_allocated_length = allocate ;
447
+ msr -> stream_input_allocated_length = allocate_length ;
448
448
}
449
449
else {
450
450
* error_msg = apr_psprintf (
451
451
msr -> mp ,
452
452
"Unable to allocate memory to hold request body on stream. Asked for %" APR_SIZE_T_FMT " bytes." ,
453
- allocate );
453
+ allocate_length );
454
454
return -1 ;
455
455
}
456
456
}
@@ -459,18 +459,18 @@ apr_status_t modsecurity_request_body_to_stream(modsec_rec *msr, const char *buf
459
459
if ((msr -> stream_input_length + buflen ) > msr -> stream_input_allocated_length ) {
460
460
461
461
// If this becomes a hotspot again, consider increasing by some percent extra each time, for fewer reallocs
462
- allocate = msr -> stream_input_length + buflen ;
462
+ allocate_length = msr -> stream_input_length + buflen ;
463
463
464
- allocated = (char * ) realloc (msr -> stream_input_data , allocate );
464
+ allocated = (char * ) realloc (msr -> stream_input_data , allocate_length );
465
465
if (allocated ) {
466
466
msr -> stream_input_data = allocated ;
467
- msr -> stream_input_allocated_length = allocate ;
467
+ msr -> stream_input_allocated_length = allocate_length ;
468
468
}
469
469
else {
470
470
* error_msg = apr_psprintf (
471
471
msr -> mp ,
472
472
"Unable to reallocate memory to hold request body on stream. Asked for %" APR_SIZE_T_FMT " bytes." ,
473
- allocate );
473
+ allocate_length );
474
474
free (msr -> stream_input_data );
475
475
return -1 ;
476
476
}
@@ -891,15 +891,15 @@ apr_status_t modsecurity_request_body_clear(modsec_rec *msr, char **error_msg) {
891
891
892
892
if (msr -> msc_reqbody_filename != NULL ) {
893
893
if (keep_body ) {
894
+ /* Move request body (which is a file) to the storage area. */
895
+ const char * put_filename = NULL ;
896
+ const char * put_basename = NULL ;
897
+
894
898
if (strcmp (msr -> txcfg -> upload_dir , msr -> txcfg -> tmp_dir ) == 0 ) {
895
899
msr_log (msr , 4 , "Not moving file to identical location." );
896
900
goto nullify ;
897
901
}
898
902
899
- /* Move request body (which is a file) to the storage area. */
900
- const char * put_filename = NULL ;
901
- const char * put_basename = NULL ;
902
-
903
903
/* Construct the new filename. */
904
904
put_basename = file_basename (msr -> msc_reqbody_mp , msr -> msc_reqbody_filename );
905
905
if (put_basename == NULL ) {
0 commit comments