Skip to content

Commit 26d2b0d

Browse files
author
Marc Stern
authored
Merge pull request #2954 from marcstern/v2/mst/optim2
remove useless memset
2 parents c2e20f6 + 931f8b6 commit 26d2b0d

File tree

1 file changed

+5
-16
lines changed

1 file changed

+5
-16
lines changed

apache2/re_operators.c

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -630,35 +630,25 @@ static int msre_op_rsub_execute(modsec_rec *msr, msre_rule *rule, msre_var *var,
630630
}
631631

632632
if(msr->stream_input_data != NULL && input_body == 1) {
633-
memset(msr->stream_input_data, 0x0, msr->stream_input_length);
634633
free(msr->stream_input_data);
635634
msr->stream_input_data = NULL;
636635
msr->stream_input_length = 0;
637636
#ifdef MSC_LARGE_STREAM_INPUT
638637
msr->stream_input_allocated_length = 0;
639-
640-
msr->stream_input_data = (char *)malloc(size);
641-
#else
642-
msr->stream_input_data = (char *)malloc(size+1);
643638
#endif
644-
639+
msr->stream_input_data = (char *)malloc(size+1);
645640
if(msr->stream_input_data == NULL) {
646641
return -1;
647642
}
648643

649644
msr->stream_input_length = size;
650645
#ifdef MSC_LARGE_STREAM_INPUT
651646
msr->stream_input_allocated_length = size;
652-
memset(msr->stream_input_data, 0x0, size);
653-
#else
654-
memset(msr->stream_input_data, 0x0, size+1);
655647
#endif
656648
msr->if_stream_changed = 1;
657649

658650
memcpy(msr->stream_input_data, data, size);
659-
#ifndef MSC_LARGE_STREAM_INPUT
660651
msr->stream_input_data[size] = '\0';
661-
#endif
662652

663653
var->value_len = size;
664654
var->value = msr->stream_input_data;
@@ -761,7 +751,6 @@ static int msre_op_validateHash_execute(modsec_rec *msr, msre_rule *rule, msre_v
761751
char *my_error_msg = NULL;
762752
int ovector[33];
763753
int rc;
764-
const char *pattern = NULL;
765754
#ifdef WITH_PCRE_STUDY
766755
#ifdef WITH_PCRE_JIT
767756
int jit = 0;
@@ -791,8 +780,8 @@ static int msre_op_validateHash_execute(modsec_rec *msr, msre_rule *rule, msre_v
791780

792781
expand_macros(msr, re_pattern, rule, msr->mp);
793782

794-
pattern = log_escape_re(msr->mp, re_pattern->value);
795783
if (msr->txcfg->debuglog_level >= 6) {
784+
const char *pattern = log_escape_re(msr->mp, re_pattern->value);
796785
msr_log(msr, 6, "Escaping pattern [%s]",pattern);
797786
}
798787

@@ -1545,10 +1534,10 @@ static const char *gsb_replace_tpath(apr_pool_t *pool, const char *domain, int l
15451534
url = apr_palloc(pool, len + 1);
15461535
data = apr_palloc(pool, len + 1);
15471536

1548-
memset(data, 0, len+1);
1549-
memset(url, 0, len+1);
1550-
1537+
data[0] = '\0';
1538+
15511539
memcpy(url, domain, len);
1540+
url[len] = 0;
15521541

15531542
while(( pos = strstr(url , "/./" )) != NULL) {
15541543
match = 1;

0 commit comments

Comments
 (0)