projects
/
project
/
firewall3.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
use calloc instead of malloc+memset
[project/firewall3.git]
/
ipsets.c
diff --git
a/ipsets.c
b/ipsets.c
index 06aafb77ecab50be9b5ffbdb8f917183e9b176b9..5b319a58e8fbf5120f3dbc08494906aadb79ce30 100644
(file)
--- a/
ipsets.c
+++ b/
ipsets.c
@@
-107,6
+107,11
@@
check_types(struct uci_element *e, struct fw3_ipset *ipset)
{
for (i = 0; i < ARRAY_SIZE(ipset_types); i++)
{
{
for (i = 0; i < ARRAY_SIZE(ipset_types); i++)
{
+ /* skip type for v6 if it does not support family */
+ if (ipset->family != FW3_FAMILY_V4 &&
+ !(ipset_types[i].optional & OPT_FAMILY))
+ continue;
+
if (ipset_types[i].types == typelist)
{
ipset->method = ipset_types[i].method;
if (ipset_types[i].types == typelist)
{
ipset->method = ipset_types[i].method;
@@
-198,13
+203,10
@@
fw3_alloc_ipset(void)
{
struct fw3_ipset *ipset;
{
struct fw3_ipset *ipset;
- ipset = malloc(sizeof(*ipset));
-
+ ipset = calloc(1, sizeof(*ipset));
if (!ipset)
return NULL;
if (!ipset)
return NULL;
- memset(ipset, 0, sizeof(*ipset));
-
INIT_LIST_HEAD(&ipset->datatypes);
ipset->enabled = true;
INIT_LIST_HEAD(&ipset->datatypes);
ipset->enabled = true;
@@
-259,6
+261,10
@@
fw3_load_ipsets(struct fw3_state *state, struct uci_package *p)
{
warn_elem(e, "must not have family 'any'");
}
{
warn_elem(e, "must not have family 'any'");
}
+ else if (ipset->iprange.set && ipset->family != ipset->iprange.family)
+ {
+ warn_elem(e, "has iprange of wrong address family");
+ }
else if (list_empty(&ipset->datatypes))
{
warn_elem(e, "has no datatypes assigned");
else if (list_empty(&ipset->datatypes))
{
warn_elem(e, "has no datatypes assigned");
@@
-292,6
+298,9
@@
create_ipset(struct fw3_ipset *ipset, struct fw3_state *state)
first = false;
}
first = false;
}
+ if (ipset->method == FW3_IPSET_METHOD_HASH)
+ fw3_pr(" family inet%s", (ipset->family == FW3_FAMILY_V4) ? "" : "6");
+
if (ipset->iprange.set)
{
fw3_pr(" range %s", fw3_address_to_string(&ipset->iprange, false));
if (ipset->iprange.set)
{
fw3_pr(" range %s", fw3_address_to_string(&ipset->iprange, false));
@@
-302,8
+311,6
@@
create_ipset(struct fw3_ipset *ipset, struct fw3_state *state)
ipset->portrange.port_min, ipset->portrange.port_max);
}
ipset->portrange.port_min, ipset->portrange.port_max);
}
- fw3_pr(" family inet%s", (ipset->family == FW3_FAMILY_V4) ? "" : "6");
-
if (ipset->timeout > 0)
fw3_pr(" timeout %u", ipset->timeout);
if (ipset->timeout > 0)
fw3_pr(" timeout %u", ipset->timeout);