mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-10-01 03:57:47 +03:00
Fixes regarding memory management
Fixes assorted issues identified by valgrind.
This commit is contained in:
@@ -958,6 +958,44 @@ int tree_contains_ip(TreeRoot *rtree,
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int add_ip_from_param(
|
||||
const char *param, TreeRoot **rtree, char **error_msg)
|
||||
{
|
||||
char *param_copy = strdup(param);
|
||||
char *saved = NULL;
|
||||
char *str = NULL;
|
||||
TreeNode *tnode = NULL;
|
||||
|
||||
str = strtok_r(param_copy, ",", &saved);
|
||||
while (str != NULL)
|
||||
{
|
||||
if (strchr(str, ':') == NULL)
|
||||
{
|
||||
tnode = TreeAddIP(str, (*rtree)->ipv4_tree, IPV4_TREE);
|
||||
}
|
||||
else
|
||||
{
|
||||
tnode = TreeAddIP(str, (*rtree)->ipv6_tree, IPV6_TREE);
|
||||
}
|
||||
|
||||
if (tnode == NULL)
|
||||
{
|
||||
//*error_msg = apr_psprintf("Could not add entry " \
|
||||
// "\"%s\" from: %s.", str, param);
|
||||
free(param_copy);
|
||||
return -1;
|
||||
}
|
||||
|
||||
str = strtok_r(NULL, ",", &saved);
|
||||
}
|
||||
free(param_copy);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int ip_tree_from_param(
|
||||
const char *param, TreeRoot **rtree, char **error_msg)
|
||||
{
|
||||
|
Reference in New Issue
Block a user