X-Git-Url: http://git.archive.openwrt.org/?p=project%2Ffirewall3.git;a=blobdiff_plain;f=options.c;h=6c5e2cf7532a1a4bf3fc90c8db055e5daa6a3267;hp=a35247f331faa374fc1c595e34227f43173e54fc;hb=865ddfd7df6a49f9346207cc105fc4f57da529c7;hpb=46536e5263c4bf57a91c38b5d08d78c774649dda diff --git a/options.c b/options.c index a35247f..6c5e2cf 100644 --- a/options.c +++ b/options.c @@ -665,7 +665,7 @@ void fw3_parse_options(void *s, const struct fw3_option *opts, struct uci_section *section) { - char *p; + char *p, *v; bool known; struct uci_element *e, *l; struct uci_option *o; @@ -720,9 +720,15 @@ fw3_parse_options(void *s, const struct fw3_option *opts, } else { - if (!o->v.string) + v = o->v.string; + + if (!v) continue; + /* protocol "tcpudp" compatibility hack */ + if (opt->parse == fw3_parse_protocol && !strcmp(v, "tcpudp")) + v = strdup("tcp udp"); + if (!opt->elem_size) { if (!opt->parse((char *)s + opt->offset, o->v.string)) @@ -730,9 +736,7 @@ fw3_parse_options(void *s, const struct fw3_option *opts, } else { - for (p = strtok(o->v.string, " \t"); - p != NULL; - p = strtok(NULL, " \t")) + for (p = strtok(v, " \t"); p != NULL; p = strtok(NULL, " \t")) { item = malloc(opt->elem_size); @@ -752,6 +756,9 @@ fw3_parse_options(void *s, const struct fw3_option *opts, list_add_tail(item, dest); } } + + if (v != o->v.string) + free(v); } known = true;