X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=acl.c;fp=acl.c;h=9bc83c2506f9083e577d8ff36d0c6953dd2d1285;hp=14edcf7d87c08617e175e0fff44e3c572e305160;hb=0b36e0a77fc750af85e969efda7bda0931f389d0;hpb=09b7971c7a862924d4ce669f8a33bda567ba570b diff --git a/acl.c b/acl.c index 14edcf7d..9bc83c25 100644 --- a/acl.c +++ b/acl.c @@ -136,30 +136,16 @@ char *acl_get_contents(struct list_head *acl) */ void acl_init(struct list_head *acl, char * const *acl_info, int num) { - int i; + char addr[16]; + int mask, i; INIT_LIST_HEAD(acl); - 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); } /**