mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-13 13:26:01 +03:00
Fix: possible segfault on reload if duplicate ip+CIDR in ip match list
This commit is contained in:
parent
49281b6c0a
commit
264dd48317
2
CHANGES
2
CHANGES
@ -1,6 +1,8 @@
|
||||
v3.x.y - YYYY-MMM-DD (to be released)
|
||||
-------------------------------------
|
||||
|
||||
- Fix: possible segfault on reload if duplicate ip+CIDR in ip match list
|
||||
[Issue #2877, #2890 - @tomsommer, @martinhsv]
|
||||
- Add some member variable inits in Transaction class
|
||||
[Issue #2886 - @GNU-Plus-Windows-User, @airween, @mdounin, @martinhsv]
|
||||
- Resolve memory leak on reload (bison-generated variable)
|
||||
|
@ -259,6 +259,7 @@ int InsertNetmask(TreeNode *node, TreeNode *parent, TreeNode *new_node,
|
||||
|
||||
node->count++;
|
||||
node->netmasks = reinterpret_cast<unsigned char *>(malloc(node->count * sizeof(unsigned char)));
|
||||
memset(node->netmasks, 0, (node->count * sizeof(unsigned char)));
|
||||
|
||||
if(node->netmasks == NULL)
|
||||
return 0;
|
||||
@ -410,6 +411,7 @@ TreeNode *CPTAddElement(unsigned char *ipdata, unsigned int ip_bitmask, CPTTree
|
||||
node->count++;
|
||||
new_node = node;
|
||||
node->netmasks = reinterpret_cast<unsigned char *>(malloc(node->count * sizeof(unsigned char)));
|
||||
memset(node->netmasks, 0, (node->count * sizeof(unsigned char)));
|
||||
|
||||
if ((node->count -1) == 0) {
|
||||
node->netmasks[0] = netmask;
|
||||
@ -418,16 +420,16 @@ TreeNode *CPTAddElement(unsigned char *ipdata, unsigned int ip_bitmask, CPTTree
|
||||
|
||||
node->netmasks[node->count - 1] = netmask;
|
||||
|
||||
i = node->count - 2;
|
||||
while (i >= 0) {
|
||||
if (netmask < node->netmasks[i]) {
|
||||
node->netmasks[i + 1] = netmask;
|
||||
int index = node->count - 2;
|
||||
while (index >= 0) {
|
||||
if (netmask < node->netmasks[index]) {
|
||||
node->netmasks[index + 1] = netmask;
|
||||
break;
|
||||
}
|
||||
|
||||
node->netmasks[i + 1] = node->netmasks[i];
|
||||
node->netmasks[i] = netmask;
|
||||
i--;
|
||||
node->netmasks[index + 1] = node->netmasks[index];
|
||||
node->netmasks[index] = netmask;
|
||||
index--;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -481,6 +483,7 @@ TreeNode *CPTAddElement(unsigned char *ipdata, unsigned int ip_bitmask, CPTTree
|
||||
}
|
||||
|
||||
i_node->netmasks = reinterpret_cast<unsigned char *>(malloc((node->count - i) * sizeof(unsigned char)));
|
||||
memset(i_node->netmasks, 0, ((node->count - i) * sizeof(unsigned char)));
|
||||
|
||||
if(i_node->netmasks == NULL) {
|
||||
free(new_node->prefix);
|
||||
|
Loading…
x
Reference in New Issue
Block a user