Skip to content

Commit 6fbdee9

Browse files
committed
Merge branch 'v3/master' of https://github.com/SpiderLabs/ModSecurity into v3/multipartpartheaderfix
2 parents 18adbb6 + a830ef6 commit 6fbdee9

File tree

17 files changed

+1022
-993
lines changed

17 files changed

+1022
-993
lines changed

.github/ISSUE_TEMPLATE/bug-report-for-version-2-x.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
---
22
name: Bug report for version 2.x
33
about: Create a report to help us improve
4+
title: ''
5+
labels: ''
6+
assignees: ''
47

58
---
69

.github/ISSUE_TEMPLATE/bug-report-for-version-3-x.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
name: Bug report for version 3.x
33
about: Create a report to help us improve. If you don't know a specific detail or
44
piece of information leave it blank, if necessary we will help you to figure out.
5+
title: ''
6+
labels: ''
7+
assignees: ''
58

69
---
710

@@ -17,7 +20,7 @@ Output of:
1720
3. Error logs
1821
4. If there is a crash, the core dump file.
1922

20-
_Notice:_ Be carefully to not leak any confidential information.
23+
_Notice:_ Be careful to not leak any confidential information.
2124

2225
**To Reproduce**
2326

@@ -33,8 +36,8 @@ A **curl** command line that mimics the original request and reproduces the prob
3336
A clear and concise description of what you expected to happen.
3437

3538
**Server (please complete the following information):**
36-
- ModSecurity version (and connector): [e.g. ModSecurity v3.0.1 with nginx-connector v1.0.0]
37-
- WebServer: [e.g. nginx-1.15.5]
39+
- ModSecurity version (and connector): [e.g. ModSecurity v3.0.8 with nginx-connector v1.0.3]
40+
- WebServer: [e.g. nginx-1.18.0]
3841
- OS (and distro): [e.g. Linux, archlinux]
3942

4043

CHANGES

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
11
v3.x.y - YYYY-MMM-DD (to be released)
22
-------------------------------------
3+
- Configure: use AS_ECHO_N instead echo -n
4+
[Issue #2894 - @liudongmiao, @martinhsv]
5+
- Adjust position of memset from 2890
6+
[Issue #2891 - @mirkodziadzka-avi, @martinhsv]
7+
- Add test: empty lines in ipMatchFromFile test
8+
[Issue #2846 - @tomsommer]
39

10+
11+
12+
v3.0.9 - 2023-Apr-12
13+
--------------------
14+
15+
- Fix: possible segfault on reload if duplicate ip+CIDR in ip match list
16+
[Issue #2877, #2890 - @tomsommer, @martinhsv]
17+
- Add some member variable inits in Transaction class (possible segfault)
18+
[Issue #2886 - @GNU-Plus-Windows-User, @airween, @mdounin, @martinhsv]
19+
- Resolve memory leak on reload (bison-generated variable)
20+
[Issue #2876 - @martinhsv]
421
- Support equals sign in XPath expressions
522
[Issue #2328 - @dennus, @martinhsv]
623
- Encode two special chars in error.log output

configure.ac

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -424,9 +424,9 @@ echo " "
424424
echo "ModSecurity - ${MSC_GIT_VERSION} for $PLATFORM"
425425
echo " "
426426
echo " Mandatory dependencies"
427-
echo -n " + libInjection ...."
427+
AS_ECHO_N(" + libInjection ....")
428428
echo LIBINJECTION_VERSION
429-
echo -n " + SecLang tests ...."
429+
AS_ECHO_N(" + SecLang tests ....")
430430
echo SECLANG_TEST_VERSION
431431

432432
echo " "
@@ -439,7 +439,7 @@ if test "x$GEOIP_FOUND" = "x0" && test "x$MAXMIND_FOUND" = "x0"; then
439439
echo " + GeoIP/MaxMind ....not found"
440440
fi
441441
if test "x$GEOIP_FOUND" = "x1" || test "x$MAXMIND_FOUND" = "x1"; then
442-
echo -n " + GeoIP/MaxMind ....found "
442+
AS_ECHO_N(" + GeoIP/MaxMind ....found ")
443443
echo ""
444444
if test "x$MAXMIND_FOUND" = "x1"; then
445445
echo " * (MaxMind) v${MAXMIND_VERSION}"
@@ -460,7 +460,7 @@ if test "x$CURL_FOUND" = "x0"; then
460460
echo " + LibCURL ....not found"
461461
fi
462462
if test "x$CURL_FOUND" = "x1"; then
463-
echo -n " + LibCURL ....found "
463+
AS_ECHO_N(" + LibCURL ....found ")
464464
if ! test "x$CURL_VERSION" = "x"; then
465465
echo "v${CURL_VERSION}"
466466
else
@@ -478,7 +478,7 @@ if test "x$YAJL_FOUND" = "x0"; then
478478
echo " + YAJL ....not found"
479479
fi
480480
if test "x$YAJL_FOUND" = "x1"; then
481-
echo -n " + YAJL ....found "
481+
AS_ECHO_N(" + YAJL ....found ")
482482
if ! test "x$YAJL_VERSION" = "x"; then
483483
echo "v${YAJL_VERSION}"
484484
else
@@ -496,7 +496,7 @@ if test "x$LMDB_FOUND" = "x0"; then
496496
echo " + LMDB ....not found"
497497
fi
498498
if test "x$LMDB_FOUND" = "x1"; then
499-
echo -n " + LMDB ....found "
499+
AS_ECHO_N(" + LMDB ....found ")
500500
if ! test "x$LMDB_VERSION" = "x"; then
501501
echo "v${LMDB_VERSION}"
502502
else
@@ -514,7 +514,7 @@ if test "x$LIBXML2_FOUND" = "x0"; then
514514
echo " + LibXML2 ....not found"
515515
fi
516516
if test "x$LIBXML2_FOUND" = "x1"; then
517-
echo -n " + LibXML2 ....found "
517+
AS_ECHO_N(" + LibXML2 ....found ")
518518
if ! test "x$LIBXML2_VERSION" = "x"; then
519519
echo "v${LIBXML2_VERSION}"
520520
else
@@ -532,7 +532,7 @@ if test "x$SSDEEP_FOUND" = "x0"; then
532532
echo " + SSDEEP ....not found"
533533
fi
534534
if test "x$SSDEEP_FOUND" = "x1"; then
535-
echo -n " + SSDEEP ....found "
535+
AS_ECHO_N(" + SSDEEP ....found ")
536536
if ! test "x$SSDEEP_VERSION" = "x"; then
537537
echo "v${SSDEEP_VERSION}"
538538
else
@@ -549,7 +549,7 @@ if test "x$LUA_FOUND" = "x0"; then
549549
echo " + LUA ....not found"
550550
fi
551551
if test "x$LUA_FOUND" = "x1"; then
552-
echo -n " + LUA ....found "
552+
AS_ECHO_N(" + LUA ....found ")
553553
if ! test "x$LUA_VERSION" = "x"; then
554554
echo "v${LUA_VERSION}"
555555
else
@@ -567,7 +567,7 @@ if test "x$PCRE2_FOUND" = "x0"; then
567567
echo " + PCRE2 ....not found"
568568
fi
569569
if test "x$PCRE2_FOUND" = "x1"; then
570-
echo -n " + PCRE2 ....found "
570+
AS_ECHO_N(" + PCRE2 ....found ")
571571
if ! test "x$PCRE2_VERSION" = "x"; then
572572
echo "v${PCRE2_VERSION}"
573573
else

headers/modsecurity/modsecurity.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* ModSecurity, http://www.modsecurity.org/
3-
* Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/)
3+
* Copyright (c) 2015 - 2023 Trustwave Holdings, Inc. (http://www.trustwave.com/)
44
*
55
* You may not use this file except in compliance with
66
* the License. You may obtain a copy of the License at
@@ -190,15 +190,15 @@ namespace modsecurity {
190190

191191
#define MODSECURITY_MAJOR "3"
192192
#define MODSECURITY_MINOR "0"
193-
#define MODSECURITY_PATCHLEVEL "8"
193+
#define MODSECURITY_PATCHLEVEL "9"
194194
#define MODSECURITY_TAG ""
195195
#define MODSECURITY_TAG_NUM "100"
196196

197197
#define MODSECURITY_VERSION MODSECURITY_MAJOR "." \
198198
MODSECURITY_MINOR "." MODSECURITY_PATCHLEVEL \
199199
MODSECURITY_TAG
200200

201-
#define MODSECURITY_VERSION_NUM 3080100
201+
#define MODSECURITY_VERSION_NUM 3090100
202202

203203
#define MODSECURITY_CHECK_VERSION(a) (MODSECURITY_VERSION_NUM <= a)
204204

src/parser/driver.cc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* ModSecurity, http://www.modsecurity.org/
3-
* Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/)
3+
* Copyright (c) 2015 - 2023 Trustwave Holdings, Inc. (http://www.trustwave.com/)
44
*
55
* You may not use this file except in compliance with
66
* the License. You may obtain a copy of the License at
@@ -34,6 +34,7 @@ Driver::Driver()
3434

3535

3636
Driver::~Driver() {
37+
3738
while (loc.empty() == false) {
3839
yy::location *a = loc.back();
3940
loc.pop_back();
@@ -42,7 +43,7 @@ Driver::~Driver() {
4243
}
4344

4445

45-
int Driver::addSecMarker(std::string marker, std::unique_ptr<std::string> fileName, int lineNumber) {
46+
int Driver::addSecMarker(const std::string& marker, std::unique_ptr<std::string> fileName, int lineNumber) {
4647
// FIXME: we might move this to the parser.
4748
for (int i = 0; i < modsecurity::Phases::NUMBER_OF_PHASES; i++) {
4849
RuleMarker *r = new RuleMarker(marker, std::unique_ptr<std::string>(new std::string(*fileName)), lineNumber);
@@ -129,9 +130,11 @@ int Driver::parse(const std::string &f, const std::string &ref) {
129130
m_lastRule = nullptr;
130131
loc.push_back(new yy::location());
131132
if (ref.empty()) {
132-
loc.back()->begin.filename = loc.back()->end.filename = new std::string("<<reference missing or not informed>>");
133+
m_filenames.push_back("<<reference missing or not informed>>");
134+
loc.back()->begin.filename = loc.back()->end.filename = &(m_filenames.back());
133135
} else {
134-
loc.back()->begin.filename = loc.back()->end.filename = new std::string(ref);
136+
m_filenames.push_back(ref);
137+
loc.back()->begin.filename = loc.back()->end.filename = &(m_filenames.back());
135138
}
136139

137140
if (f.empty()) {

src/parser/driver.h

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* ModSecurity, http://www.modsecurity.org/
3-
* Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/)
3+
* Copyright (c) 2015 - 2023 Trustwave Holdings, Inc. (http://www.trustwave.com/)
44
*
55
* You may not use this file except in compliance with
66
* the License. You may obtain a copy of the License at
@@ -53,22 +53,14 @@ typedef struct Driver_t Driver;
5353
#endif
5454

5555

56-
/**
57-
*
58-
* FIXME: There is a memory leak in the filename at yy::location.
59-
* The filename should be converted into a shared string to
60-
* save memory or be associated with the life cycle of the
61-
* driver class.
62-
*
63-
**/
6456
class Driver : public RulesSetProperties {
6557
public:
6658
Driver();
6759
virtual ~Driver();
6860

6961
int addSecRule(std::unique_ptr<RuleWithActions> rule);
7062
int addSecAction(std::unique_ptr<RuleWithActions> rule);
71-
int addSecMarker(std::string marker, std::unique_ptr<std::string> fileName, int lineNumber);
63+
int addSecMarker(const std::string& marker, std::unique_ptr<std::string> fileName, int lineNumber);
7264
int addSecRuleScript(std::unique_ptr<RuleScript> rule);
7365

7466
bool scan_begin();
@@ -92,6 +84,13 @@ class Driver : public RulesSetProperties {
9284
RuleWithActions *m_lastRule;
9385

9486
RulesSetPhases m_rulesSetPhases;
87+
88+
// Retain a list of new'd filenames so that they are available during the lifetime
89+
// of the Driver object, but so that they will get cleaned up by the Driver
90+
// destructor. This is to resolve a memory leak of yy.position.filename in location.hh.
91+
// Ordinarily other solutions would have been preferable, but location.hh is a
92+
// bison-generated file, which makes some alternative solutions impractical.
93+
std::list<std::string> m_filenames;
9594
};
9695

9796

0 commit comments

Comments
 (0)