firewall3: add fw3_attr_parse_name_type() function
[project/firewall3.git] / ipsets.c
index 8f88885546c68bb16f124294c51b073d10be68a2..7a72fd35a378941304c8308f75f65b91ae6fc8d3 100644 (file)
--- a/ipsets.c
+++ b/ipsets.c
@@ -1,7 +1,7 @@
 /*
  * firewall3 - 3rd OpenWrt UCI firewall implementation
  *
- *   Copyright (C) 2013 Jo-Philipp Wich <jow@openwrt.org>
+ *   Copyright (C) 2013 Jo-Philipp Wich <jo@mein.io>
  *
  * Permission to use, copy, modify, and/or distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -203,13 +203,10 @@ fw3_alloc_ipset(void)
 {
        struct fw3_ipset *ipset;
 
-       ipset = malloc(sizeof(*ipset));
-
+       ipset = calloc(1, sizeof(*ipset));
        if (!ipset)
                return NULL;
 
-       memset(ipset, 0, sizeof(*ipset));
-
        INIT_LIST_HEAD(&ipset->datatypes);
 
        ipset->enabled = true;
@@ -242,7 +239,8 @@ fw3_load_ipsets(struct fw3_state *state, struct uci_package *p)
                if (!ipset)
                        continue;
 
-               fw3_parse_options(ipset, fw3_ipset_opts, s);
+               if (!fw3_parse_options(ipset, fw3_ipset_opts, s))
+                       warn_elem(e, "has invalid options");
 
                if (ipset->external)
                {
@@ -306,7 +304,7 @@ create_ipset(struct fw3_ipset *ipset, struct fw3_state *state)
 
        if (ipset->iprange.set)
        {
-               fw3_pr(" range %s", fw3_address_to_string(&ipset->iprange, false));
+               fw3_pr(" range %s", fw3_address_to_string(&ipset->iprange, false, true));
        }
        else if (ipset->portrange.set)
        {