mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-13 21:36:00 +03:00
Fix memory leaks in lmdb code (new'd strings)
This commit is contained in:
parent
8594cb8a7d
commit
dc2e38e242
2
CHANGES
2
CHANGES
@ -1,6 +1,8 @@
|
|||||||
v3.x.y - YYYY-MMM-DD (to be released)
|
v3.x.y - YYYY-MMM-DD (to be released)
|
||||||
-------------------------------------
|
-------------------------------------
|
||||||
|
|
||||||
|
- Fix memory leaks in lmdb code (new'd strings)
|
||||||
|
[Issue #2983 - @martinhsv]
|
||||||
- Configure: add additional name to pcre2 pkg-config list
|
- Configure: add additional name to pcre2 pkg-config list
|
||||||
[Issue #2939 - @agebhar1, @fzipi, @martinhsv]
|
[Issue #2939 - @agebhar1, @fzipi, @martinhsv]
|
||||||
|
|
||||||
|
@ -253,10 +253,8 @@ void LMDB::resolveSingleMatch(const std::string& var,
|
|||||||
mdb_cursor_open(txn, m_dbi, &cursor);
|
mdb_cursor_open(txn, m_dbi, &cursor);
|
||||||
while ((rc = mdb_cursor_get(cursor, &mdb_key,
|
while ((rc = mdb_cursor_get(cursor, &mdb_key,
|
||||||
&mdb_value_ret, MDB_NEXT_DUP)) == 0) {
|
&mdb_value_ret, MDB_NEXT_DUP)) == 0) {
|
||||||
std::string *a = new std::string(
|
std::string a(reinterpret_cast<char *>(mdb_value_ret.mv_data), mdb_value_ret.mv_size);
|
||||||
reinterpret_cast<char *>(mdb_value_ret.mv_data),
|
VariableValue *v = new VariableValue(&var, &a);
|
||||||
mdb_value_ret.mv_size);
|
|
||||||
VariableValue *v = new VariableValue(&var, a);
|
|
||||||
l->push_back(v);
|
l->push_back(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -427,23 +425,18 @@ void LMDB::resolveMultiMatches(const std::string& var,
|
|||||||
|
|
||||||
if (keySize == 0) {
|
if (keySize == 0) {
|
||||||
while ((rc = mdb_cursor_get(cursor, &key, &data, MDB_NEXT)) == 0) {
|
while ((rc = mdb_cursor_get(cursor, &key, &data, MDB_NEXT)) == 0) {
|
||||||
|
std::string key_to_insert(reinterpret_cast<char *>(key.mv_data), key.mv_size);
|
||||||
|
std::string value_to_insert(reinterpret_cast<char *>(data.mv_data), data.mv_size);
|
||||||
l->insert(l->begin(), new VariableValue(
|
l->insert(l->begin(), new VariableValue(
|
||||||
&m_name,
|
&m_name, &key_to_insert, &value_to_insert));
|
||||||
new std::string(reinterpret_cast<char *>(key.mv_data),
|
|
||||||
key.mv_size),
|
|
||||||
new std::string(reinterpret_cast<char *>(data.mv_data),
|
|
||||||
data.mv_size)));
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
while ((rc = mdb_cursor_get(cursor, &key, &data, MDB_NEXT)) == 0) {
|
while ((rc = mdb_cursor_get(cursor, &key, &data, MDB_NEXT)) == 0) {
|
||||||
char *a = reinterpret_cast<char *>(key.mv_data);
|
char *a = reinterpret_cast<char *>(key.mv_data);
|
||||||
if (strncmp(var.c_str(), a, keySize) == 0) {
|
if (strncmp(var.c_str(), a, keySize) == 0) {
|
||||||
l->insert(l->begin(), new VariableValue(
|
std::string key_to_insert(reinterpret_cast<char *>(key.mv_data), key.mv_size);
|
||||||
&m_name,
|
std::string value_to_insert(reinterpret_cast<char *>(data.mv_data), data.mv_size);
|
||||||
new std::string(reinterpret_cast<char *>(key.mv_data),
|
l->insert(l->begin(), new VariableValue(&m_name, &key_to_insert, &value_to_insert));
|
||||||
key.mv_size),
|
|
||||||
new std::string(reinterpret_cast<char *>(data.mv_data),
|
|
||||||
data.mv_size)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -485,16 +478,13 @@ void LMDB::resolveRegularExpression(const std::string& var,
|
|||||||
if (ret <= 0) {
|
if (ret <= 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (ke.toOmit(std::string(reinterpret_cast<char *>(key.mv_data),
|
std::string key_to_insert(reinterpret_cast<char *>(key.mv_data), key.mv_size);
|
||||||
key.mv_size))) {
|
if (ke.toOmit(key_to_insert)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
VariableValue *v = new VariableValue(
|
std::string value_to_insert(reinterpret_cast<char *>(data.mv_data), data.mv_size);
|
||||||
new std::string(reinterpret_cast<char *>(key.mv_data),
|
VariableValue *v = new VariableValue(&key_to_insert, &value_to_insert);
|
||||||
key.mv_size),
|
|
||||||
new std::string(reinterpret_cast<char *>(data.mv_data),
|
|
||||||
data.mv_size));
|
|
||||||
l->insert(l->begin(), v);
|
l->insert(l->begin(), v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user