mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-30 03:34:29 +03:00
Fixes regarding memory management
Fixes assorted issues identified by valgrind.
This commit is contained in:
@@ -27,6 +27,7 @@ CustomDebugLog *CustomDebugLog::new_instance() {
|
||||
return new CustomDebugLog();
|
||||
}
|
||||
|
||||
CustomDebugLog::~CustomDebugLog() { }
|
||||
|
||||
void CustomDebugLog::write(int level, const std::string& message) {
|
||||
m_log << "[" << level << "] " << message << std::endl;
|
||||
@@ -35,7 +36,6 @@ void CustomDebugLog::write(int level, const std::string& message) {
|
||||
|
||||
bool CustomDebugLog::contains(const std::string& pattern) {
|
||||
modsecurity::Utils::Regex re(pattern);
|
||||
modsecurity::Utils::SMatch match;
|
||||
std::string s = m_log.str();
|
||||
return modsecurity::Utils::regex_search(s, re);
|
||||
}
|
||||
|
@@ -26,6 +26,7 @@ namespace modsecurity_test {
|
||||
class CustomDebugLog : public modsecurity::DebugLog {
|
||||
public:
|
||||
CustomDebugLog *new_instance();
|
||||
~CustomDebugLog();
|
||||
|
||||
void write(int level, const std::string& message) override;
|
||||
bool contains(const std::string& pattern);
|
||||
|
@@ -134,6 +134,11 @@ void perform_unit_test(ModSecurityTest<RegressionTest> *test,
|
||||
std::cout << KCYN << "skipped!" << RESET << std::endl;
|
||||
}
|
||||
res->push_back(testRes);
|
||||
|
||||
delete modsec_transaction;
|
||||
delete modsec_rules;
|
||||
delete modsec;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -156,6 +161,11 @@ void perform_unit_test(ModSecurityTest<RegressionTest> *test,
|
||||
<< std::endl;
|
||||
testRes->passed = false;
|
||||
res->push_back(testRes);
|
||||
|
||||
delete modsec_transaction;
|
||||
delete modsec_rules;
|
||||
delete modsec;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -174,6 +184,11 @@ void perform_unit_test(ModSecurityTest<RegressionTest> *test,
|
||||
testRes->reason << KGRN << "passed!" << RESET << std::endl;
|
||||
testRes->passed = true;
|
||||
res->push_back(testRes);
|
||||
|
||||
delete modsec_transaction;
|
||||
delete modsec_rules;
|
||||
delete modsec;
|
||||
|
||||
continue;
|
||||
} else {
|
||||
/* Parser error was expected, but with a different content */
|
||||
@@ -193,6 +208,11 @@ void perform_unit_test(ModSecurityTest<RegressionTest> *test,
|
||||
<< s << std::endl;
|
||||
testRes->passed = false;
|
||||
res->push_back(testRes);
|
||||
|
||||
delete modsec_transaction;
|
||||
delete modsec_rules;
|
||||
delete modsec;
|
||||
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
@@ -210,6 +230,11 @@ void perform_unit_test(ModSecurityTest<RegressionTest> *test,
|
||||
}
|
||||
testRes->passed = false;
|
||||
res->push_back(testRes);
|
||||
|
||||
delete modsec_transaction;
|
||||
delete modsec_rules;
|
||||
delete modsec;
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -340,7 +365,6 @@ after_debug_log:
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
ModSecurityTest<RegressionTest> test;
|
||||
ModSecurityTestResults<RegressionTest> results;
|
||||
int test_number = 0;
|
||||
|
||||
#ifdef WITH_GEOIP
|
||||
@@ -414,6 +438,7 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
failed++;
|
||||
}
|
||||
delete r;
|
||||
}
|
||||
|
||||
if (!test.m_automake_output) {
|
||||
@@ -439,6 +464,7 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
delete vec;
|
||||
}
|
||||
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
@@ -47,7 +47,7 @@ void print_help() {
|
||||
|
||||
void perform_unit_test(ModSecurityTest<UnitTest> *test, UnitTest *t,
|
||||
ModSecurityTestResults<UnitTest>* res) {
|
||||
const char *error = NULL;
|
||||
std::string error;
|
||||
|
||||
if (test->m_automake_output) {
|
||||
std::cout << ":test-result: ";
|
||||
|
@@ -1,3 +1,26 @@
|
||||
{
|
||||
<insert_a_suppression_name_here>
|
||||
Memcheck:Leak
|
||||
match-leak-kinds: definite
|
||||
fun:_Znwm
|
||||
fun:_ZN11modsecurity9operators8Operator11instantiateENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
|
||||
fun:_ZN2yy14seclang_parser5parseEv
|
||||
fun:_ZN11modsecurity6Parser6Driver5parseERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES9_
|
||||
fun:_ZN11modsecurity5Rules4loadEPKcRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
|
||||
fun:_Z17perform_unit_testPN16modsecurity_test15ModSecurityTestINS_14RegressionTestEEEPSt6vectorIPS1_SaIS5_EEPNS_22ModSecurityTestResultsINS_20RegressionTestResultEEEPi
|
||||
fun:main
|
||||
}
|
||||
{
|
||||
<insert_a_suppression_name_here>
|
||||
Memcheck:Leak
|
||||
match-leak-kinds: definite
|
||||
fun:_Znwm
|
||||
fun:_ZN2yy14seclang_parser5parseEv
|
||||
fun:_ZN11modsecurity6Parser6Driver5parseERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES9_
|
||||
fun:_ZN11modsecurity5Rules4loadEPKcRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
|
||||
fun:_Z17perform_unit_testPN16modsecurity_test15ModSecurityTestINS_14RegressionTestEEEPSt6vectorIPS1_SaIS5_EEPNS_22ModSecurityTestResultsINS_20RegressionTestResultEEEPi
|
||||
fun:main
|
||||
}
|
||||
{
|
||||
<insert_a_suppression_name_here>
|
||||
Memcheck:Leak
|
||||
@@ -73,4 +96,16 @@
|
||||
fun:_Z17perform_unit_testPSt6vectorIPN16modsecurity_test14RegressionTestESaIS2_EEPNS0_22ModSecurityTestResultsIS1_EEPi
|
||||
fun:main
|
||||
}
|
||||
{
|
||||
<insert_a_suppression_name_here>
|
||||
Memcheck:Leak
|
||||
match-leak-kinds: definite
|
||||
fun:_Znwm
|
||||
fun:_ZN11modsecurity7actions6Action11instantiateERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
|
||||
fun:_ZN2yy14seclang_parser5parseEv
|
||||
fun:_ZN11modsecurity6Parser6Driver5parseERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES9_
|
||||
fun:_ZN11modsecurity5Rules4loadEPKcRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
|
||||
fun:_Z17perform_unit_testPN16modsecurity_test15ModSecurityTestINS_14RegressionTestEEEPSt6vectorIPS1_SaIS5_EEPNS_22ModSecurityTestResultsINS_20RegressionTestResultEEEPi
|
||||
fun:main
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user