- for (i = 0; i < num; i++) {
- char *arg = para_strdup(acl_info[i]);
- char *p = strchr(arg, '/');
- int netmask;
-
- if (!p)
- goto err;
- *p = '\0';
- if (!is_valid_ipv4_address(arg))
- goto err;
- netmask = atoi(++p);
- if (netmask < 0 || netmask > 32)
- goto err;
- acl_add_entry(acl, arg, netmask);
- goto success;
-err:
- PARA_CRIT_LOG("syntax error: %s\n", acl_info[i]);
-success:
- free(arg);
- continue;
- }
+ for (i = 0; i < num; i++)
+ if (parse_cidr(acl_info[i], addr, sizeof(addr), &mask) == NULL)
+ PARA_CRIT_LOG("ACL syntax error: %s, ignoring\n",
+ acl_info[i]);
+ else
+ acl_add_entry(acl, addr, mask);