From: Steven Barth Date: Tue, 15 Oct 2013 07:31:33 +0000 (+0200) Subject: Avoid segfaults when parsing configuration X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=b9ffc26a2d12b9769d1c519d8c851b7c9301e82c;p=oweals%2Fodhcpd.git Avoid segfaults when parsing configuration --- diff --git a/src/config.c b/src/config.c index 9228a37..e455965 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;