Avoids to cleanup GeoIp on ModSecurity destructor

GeoIp is already being cleaned elsewhere.

Fix #2041
This commit is contained in:
Felipe Zimmerle 2020-11-16 11:39:26 -03:00
parent d242f0cd54
commit ec7d2db400
No known key found for this signature in database
GPG Key ID: E6DFB08CE8B11277
5 changed files with 19 additions and 13 deletions

View File

@ -1,6 +1,8 @@
v3.x.y - YYYY-MMM-DD (to be released)
-------------------------------------
- Avoids to cleanup GeoIp on ModSecurity destructor
[#2041 - @zimmerle, @jptosso, @victorhora]
- Fix memory leak of RuleMessages objects
[#2376 - @WGH-, @martinhsv]
- Produce not-supported error for ctl:forceRequestBodyVariable

View File

@ -95,9 +95,6 @@ ModSecurity::~ModSecurity() {
#ifdef MSC_WITH_CURL
curl_global_cleanup();
#endif
#ifdef WITH_GEOIP
Utils::GeoLookup::getInstance().cleanUp();
#endif
#ifdef WITH_LIBXML2
xmlCleanupParser();
#endif

View File

@ -63,22 +63,26 @@ bool GeoLookup::setDataBase(const std::string& filePath,
std::string intGeo;
#endif
if (m_version != NOT_LOADED) {
cleanUp();
}
#ifdef WITH_MAXMIND
int status = MMDB_open(filePath.c_str(), MMDB_MODE_MMAP, &mmdb);
if (status != MMDB_SUCCESS) {
intMax.assign("libMaxMind: Can't open: " + std::string(MMDB_strerror(status)) + ".");
} else {
if (status == MMDB_SUCCESS) {
m_version = VERSION_MAXMIND;
} else {
intMax.assign("libMaxMind: Can't open: " + std::string(MMDB_strerror(status)) + ".");
}
#endif
#ifdef WITH_GEOIP
if (m_version == NOT_LOADED) {
m_gi = GeoIP_open(filePath.c_str(), GEOIP_MEMORY_CACHE);
if (m_gi == NULL) {
intGeo.append("GeoIP: Can't open: " + filePath + ".");
} else {
if (m_gi) {
m_version = VERSION_GEOIP;
} else {
intGeo.append("GeoIP: Can't open: " + filePath + ".");
}
}
#endif

View File

@ -55,13 +55,16 @@ class GeoLookup {
private:
GeoLookup() :
m_version(NOT_LOADED)
#if WITH_MAXMIND
,mmdb()
#endif
#if WITH_GEOIP
,m_gi(NULL)
#endif
{ }
~GeoLookup();
GeoLookup(GeoLookup const&);
void operator=(GeoLookup const&);
GeoLookup(GeoLookup const&) = delete;
void operator=(GeoLookup const&) = delete;
GeoLookupVersion m_version;
#if WITH_MAXMIND

View File

@ -51,14 +51,14 @@ functionStatic:src/engine/lua.h:80
functionConst:src/utils/geo_lookup.h:49
useInitializationList:src/operators/rbl.h:69
constStatement:test/common/modsecurity_test.cc:82
danglingTemporaryLifetime:src/modsecurity.cc:204
danglingTemporaryLifetime:src/modsecurity.cc:201
functionStatic:src/operators/geo_lookup.h:35
duplicateBreak:src/operators/validate_utf8_encoding.cc
duplicateBranch:src/request_body_processor/multipart.cc:91
syntaxError:src/transaction.cc:62
noConstructor:src/variables/variable.h:152
duplicateBranch:src/request_body_processor/multipart.cc:93
danglingTempReference:src/modsecurity.cc:204
danglingTempReference:src/modsecurity.cc:201
knownConditionTrueFalse:src/operators/validate_url_encoding.cc:79
knownConditionTrueFalse:src/operators/verify_svnr.cc:90
noConstructor:src/actions/rule_id.h:30