Fix parsing of ipset datatypes
authorJo-Philipp Wich <jow@openwrt.org>
Tue, 30 Apr 2013 18:26:44 +0000 (20:26 +0200)
committerJo-Philipp Wich <jow@openwrt.org>
Tue, 30 Apr 2013 18:51:42 +0000 (20:51 +0200)
options.c

index 8315aafc3649ac04c32fe08e63218a95d2dacebf..724a2153dfc816b72657db172d3b348ea1da6003 100644 (file)
--- a/options.c
+++ b/options.c
@@ -565,26 +565,32 @@ fw3_parse_ipset_method(void *ptr, const char *val, bool is_list)
 bool
 fw3_parse_ipset_datatype(void *ptr, const char *val, bool is_list)
 {
-       struct fw3_ipset_datatype *type = ptr;
+       struct fw3_ipset_datatype type = { };
 
        if (!strncmp(val, "dest_", 5))
        {
                val += 5;
-               type->dest = true;
+               type.dest = true;
        }
        else if (!strncmp(val, "dst_", 4))
        {
                val += 4;
-               type->dest = true;
+               type.dest = true;
        }
        else if (!strncmp(val, "src_", 4))
        {
                val += 4;
-               type->dest = false;
+               type.dest = false;
        }
 
-       return parse_enum(&type->type, val, ipset_types,
-                         FW3_IPSET_TYPE_IP, FW3_IPSET_TYPE_SET);
+       if (parse_enum(&type.type, val, ipset_types,
+                      FW3_IPSET_TYPE_IP, FW3_IPSET_TYPE_SET))
+       {
+               put_value(ptr, &type, sizeof(type), is_list);
+               return true;
+       }
+
+       return false;
 }
 
 bool