Skip to content

Commit 2065631

Browse files
authored
Merge pull request #3074 from airween/v2/fixbuildissue
V2/fixbuildissue
2 parents b9df8ee + 1d682c0 commit 2065631

File tree

2 files changed

+16
-33
lines changed

2 files changed

+16
-33
lines changed

CHANGES

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,6 @@
11
DD mmm YYYY - 2.9.x (to be released)
22
-------------------
33

4-
* Support for PCRE2 in Windows
5-
[PR #2931, @leancz]
6-
* Fix ; incorrectly replaced by space in t:cmdline
7-
[PR #3051, @marcstern]
8-
* Add some syntax validation
9-
[PR #2994, @marcstern]
10-
* Optimize macro processing
11-
[PR #2992/3004, @marcstern]
12-
* Add detailed error message when writing collections
13-
[PR #3050, @marcstern]
14-
* Add context info to error message
15-
[PR #2997, @marcstern]
16-
* Fix ctl:ruleRemoveByTag that isn't executed if no rule id is present
17-
[PR #3012, @marcstern]
18-
* Ignore empty action instead of storing it
19-
[PR #3003, @marcstern]
20-
* Fixed memory leak if builded modsecurity with --enable-pcre-study
21-
[Issue #610, @marcstern]
22-
* Remove useless code
23-
[PR #2953/2954, @marcstern]
24-
* Centralized function to get user name, compatible with Linux & Windows
25-
[PR #2956, @marcstern]
26-
* Compatibility with libyajl decoding the buffer inline
27-
[PR #2957, @marcstern]
28-
* Fixed memory leaks
29-
[PR #2960/2963/2969, @marcstern]
30-
* Fixed uninitialized variable
31-
[PR #2987, @marcstern]
324
* Set the minimum security protocol version for SecRemoteRules
335
[Issue security/code-scanning/2 - @airween]
346
* Allow lua version 5.4

apache2/re_operators.c

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -630,25 +630,35 @@ 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);
633634
free(msr->stream_input_data);
634635
msr->stream_input_data = NULL;
635636
msr->stream_input_length = 0;
636637
#ifdef MSC_LARGE_STREAM_INPUT
637638
msr->stream_input_allocated_length = 0;
638-
#endif
639+
640+
msr->stream_input_data = (char *)malloc(size);
641+
#else
639642
msr->stream_input_data = (char *)malloc(size+1);
643+
#endif
644+
640645
if(msr->stream_input_data == NULL) {
641646
return -1;
642647
}
643648

644649
msr->stream_input_length = size;
645650
#ifdef MSC_LARGE_STREAM_INPUT
646651
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);
647655
#endif
648656
msr->if_stream_changed = 1;
649657

650658
memcpy(msr->stream_input_data, data, size);
659+
#ifndef MSC_LARGE_STREAM_INPUT
651660
msr->stream_input_data[size] = '\0';
661+
#endif
652662

653663
var->value_len = size;
654664
var->value = msr->stream_input_data;
@@ -751,6 +761,7 @@ static int msre_op_validateHash_execute(modsec_rec *msr, msre_rule *rule, msre_v
751761
char *my_error_msg = NULL;
752762
int ovector[33];
753763
int rc;
764+
const char *pattern = NULL;
754765
#ifdef WITH_PCRE_STUDY
755766
#ifdef WITH_PCRE_JIT
756767
int jit;
@@ -780,7 +791,7 @@ static int msre_op_validateHash_execute(modsec_rec *msr, msre_rule *rule, msre_v
780791

781792
expand_macros(msr, re_pattern, rule, msr->mp);
782793

783-
const char *pattern = log_escape_re(msr->mp, re_pattern->value);
794+
pattern = log_escape_re(msr->mp, re_pattern->value);
784795
if (msr->txcfg->debuglog_level >= 6) {
785796
msr_log(msr, 6, "Escaping pattern [%s]",pattern);
786797
}
@@ -1534,10 +1545,10 @@ static const char *gsb_replace_tpath(apr_pool_t *pool, const char *domain, int l
15341545
url = apr_palloc(pool, len + 1);
15351546
data = apr_palloc(pool, len + 1);
15361547

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

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

0 commit comments

Comments
 (0)