Skip to content

Commit 97b51eb

Browse files
allanrboFelipe Zimmerle
authored andcommitted
Renamed local var and initialized local vars. Undid accidental move.
1 parent afae690 commit 97b51eb

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

apache2/msc_reqbody.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -428,29 +428,29 @@ apr_status_t modsecurity_request_body_store(modsec_rec *msr,
428428
}
429429

430430
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;
433433

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 = msr->request_content_length;
437+
allocate_length = msr->request_content_length;
438438
}
439439
else {
440440
// 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;
442442
}
443443

444-
allocated = (char*) calloc(allocate, sizeof(char));
444+
allocated = (char*) calloc(allocate_length, sizeof(char));
445445
if (allocated) {
446446
msr->stream_input_data = allocated;
447-
msr->stream_input_allocated_length = allocate;
447+
msr->stream_input_allocated_length = allocate_length;
448448
}
449449
else {
450450
*error_msg = apr_psprintf(
451451
msr->mp,
452452
"Unable to allocate memory to hold request body on stream. Asked for %" APR_SIZE_T_FMT " bytes.",
453-
allocate);
453+
allocate_length);
454454
return -1;
455455
}
456456
}
@@ -459,18 +459,18 @@ apr_status_t modsecurity_request_body_to_stream(modsec_rec *msr, const char *buf
459459
if ((msr->stream_input_length + buflen) > msr->stream_input_allocated_length) {
460460

461461
// 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;
463463

464-
allocated = (char*) realloc(msr->stream_input_data, allocate);
464+
allocated = (char*) realloc(msr->stream_input_data, allocate_length);
465465
if (allocated) {
466466
msr->stream_input_data = allocated;
467-
msr->stream_input_allocated_length = allocate;
467+
msr->stream_input_allocated_length = allocate_length;
468468
}
469469
else {
470470
*error_msg = apr_psprintf(
471471
msr->mp,
472472
"Unable to reallocate memory to hold request body on stream. Asked for %" APR_SIZE_T_FMT " bytes.",
473-
allocate);
473+
allocate_length);
474474
free(msr->stream_input_data);
475475
return -1;
476476
}
@@ -891,15 +891,15 @@ apr_status_t modsecurity_request_body_clear(modsec_rec *msr, char **error_msg) {
891891

892892
if (msr->msc_reqbody_filename != NULL) {
893893
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+
894898
if (strcmp(msr->txcfg->upload_dir, msr->txcfg->tmp_dir) == 0) {
895899
msr_log(msr, 4, "Not moving file to identical location.");
896900
goto nullify;
897901
}
898902

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-
903903
/* Construct the new filename. */
904904
put_basename = file_basename(msr->msc_reqbody_mp, msr->msc_reqbody_filename);
905905
if (put_basename == NULL) {

0 commit comments

Comments
 (0)