X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fodhcpd.git;a=blobdiff_plain;f=src%2Fconfig.c;h=4aaded9f342e1b72c440956987bf6c4d6e8a8c35;hp=ebc664262d8331788ec31449446c6ab946d55d9f;hb=8cc7121600eab0e28495e48f559d4886ba879c95;hpb=78c5e4b032c420852abc2a9e1e6f429a4d803c21 diff --git a/src/config.c b/src/config.c index ebc6642..4aaded9 100644 --- a/src/config.c +++ b/src/config.c @@ -260,7 +260,10 @@ int config_parse_interface(struct blob_attr *b, const char *name, bool overwrite blobmsg_parse(iface_attrs, IFACE_ATTR_MAX, tb, blob_data(b), blob_len(b)); if (tb[IFACE_ATTR_INTERFACE]) - name = blobmsg_data(tb[IFACE_ATTR_INTERFACE]); + name = blobmsg_get_string(tb[IFACE_ATTR_INTERFACE]); + + if (!name) + return -1; struct interface *iface = get_interface(name); if (!iface) { @@ -281,6 +284,9 @@ int config_parse_interface(struct blob_attr *b, const char *name, bool overwrite else if ((c = tb[IFACE_ATTR_NETWORKID])) ifname = blobmsg_get_string(c); + if (!ifname) + return -1; + strncpy(iface->ifname, ifname, sizeof(iface->ifname) - 1); iface->inuse = true; @@ -331,7 +337,7 @@ int config_parse_interface(struct blob_attr *b, const char *name, bool overwrite if ((c = tb[IFACE_ATTR_UPSTREAM])) { struct blob_attr *cur; - int rem; + unsigned rem; blobmsg_for_each_attr(cur, c, rem) { if (blobmsg_type(cur) != BLOBMSG_TYPE_STRING || !blobmsg_check_attr(cur, NULL)) @@ -344,25 +350,38 @@ int config_parse_interface(struct blob_attr *b, const char *name, bool overwrite } } - if ((c = tb[IFACE_ATTR_RA])) - if ((iface->ra = parse_mode(blobmsg_get_string(c))) < 0) + int mode; + if ((c = tb[IFACE_ATTR_RA])) { + if ((mode = parse_mode(blobmsg_get_string(c))) >= 0) + iface->ra = mode; + else goto err; + } - if ((c = tb[IFACE_ATTR_DHCPV4])) - if ((iface->dhcpv4 = parse_mode(blobmsg_get_string(c))) < 0) + if ((c = tb[IFACE_ATTR_DHCPV4])) { + if ((mode = parse_mode(blobmsg_get_string(c))) >= 0) + iface->dhcpv4 = mode; + else goto err; + } - if ((c = tb[IFACE_ATTR_DHCPV6])) - if ((iface->dhcpv6 = parse_mode(blobmsg_get_string(c))) < 0) + if ((c = tb[IFACE_ATTR_DHCPV6])) { + if ((mode = parse_mode(blobmsg_get_string(c))) >= 0) + iface->dhcpv6 = mode; + else goto err; + } - if ((c = tb[IFACE_ATTR_NDP])) - if ((iface->ndp = parse_mode(blobmsg_get_string(c))) < 0) + if ((c = tb[IFACE_ATTR_NDP])) { + if ((mode = parse_mode(blobmsg_get_string(c))) >= 0) + iface->ndp = mode; + else goto err; + } if ((c = tb[IFACE_ATTR_DNS])) { struct blob_attr *cur; - int rem; + unsigned rem; iface->always_rewrite_dns = true; blobmsg_for_each_attr(cur, c, rem) { @@ -387,7 +406,7 @@ int config_parse_interface(struct blob_attr *b, const char *name, bool overwrite if ((c = tb[IFACE_ATTR_DOMAIN])) { struct blob_attr *cur; - int rem; + unsigned rem; blobmsg_for_each_attr(cur, c, rem) { if (blobmsg_type(cur) != BLOBMSG_TYPE_STRING || !blobmsg_check_attr(cur, NULL)) @@ -437,7 +456,7 @@ int config_parse_interface(struct blob_attr *b, const char *name, bool overwrite if ((c = tb[IFACE_ATTR_NDPROXY_STATIC])) { struct blob_attr *cur; - int rem; + unsigned rem; blobmsg_for_each_attr(cur, c, rem) { if (blobmsg_type(cur) != BLOBMSG_TYPE_STRING || !blobmsg_check_attr(cur, NULL)) @@ -466,7 +485,7 @@ static int set_interface(struct uci_section *s) } -static volatile bool do_reload = false; +static volatile int do_reload = false; static void set_stop(int signal) { uloop_end(); @@ -481,7 +500,7 @@ void odhcpd_run(void) signal(SIGINT, set_stop); do { - do_reload = false; + do_reload = uloop_cancelled = false; struct lease *l; list_for_each_entry(l, &leases, head) { @@ -513,7 +532,7 @@ void odhcpd_run(void) #endif // Evaluate hybrid mode for master - struct interface *master = NULL, *i; + struct interface *master = NULL, *i, *n; list_for_each_entry(i, &interfaces, head) { if (!i->master) continue; @@ -538,7 +557,7 @@ void odhcpd_run(void) } - list_for_each_entry(i, &interfaces, head) { + list_for_each_entry_safe(i, n, &interfaces, head) { if (i->inuse && !i->ignore) { // Resolve hybrid mode if (i->dhcpv6 == RELAYD_HYBRID)