Skip to content

Commit 8a3b620

Browse files
authored
Merge pull request owasp-modsecurity#3153 from marcstern/v2/LARGE_STREAM_INPUT_nullend
Missing null byte + optimization
2 parents 719744e + 4a992b5 commit 8a3b620

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

apache2/re_operators.c

+1-10
Original file line numberDiff line numberDiff line change
@@ -649,29 +649,20 @@ static int msre_op_rsub_execute(modsec_rec *msr, msre_rule *rule, msre_var *var,
649649
msr->stream_input_length = 0;
650650
#ifdef MSC_LARGE_STREAM_INPUT
651651
msr->stream_input_allocated_length = 0;
652-
653-
msr->stream_input_data = (char *)malloc(size);
654-
#else
655-
msr->stream_input_data = (char *)malloc(size+1);
656652
#endif
657-
653+
msr->stream_input_data = (char *)malloc(size+1);
658654
if(msr->stream_input_data == NULL) {
659655
return -1;
660656
}
661657

662658
msr->stream_input_length = size;
663659
#ifdef MSC_LARGE_STREAM_INPUT
664660
msr->stream_input_allocated_length = size;
665-
memset(msr->stream_input_data, 0x0, size);
666-
#else
667-
memset(msr->stream_input_data, 0x0, size+1);
668661
#endif
669662
msr->if_stream_changed = 1;
670663

671664
memcpy(msr->stream_input_data, data, size);
672-
#ifndef MSC_LARGE_STREAM_INPUT
673665
msr->stream_input_data[size] = '\0';
674-
#endif
675666

676667
var->value_len = size;
677668
var->value = msr->stream_input_data;

0 commit comments

Comments
 (0)