From b9ffc26a2d12b9769d1c519d8c851b7c9301e82c Mon Sep 17 00:00:00 2001 From: Steven Barth Date: Tue, 15 Oct 2013 09:31:33 +0200 Subject: [PATCH] Avoid segfaults when parsing configuration --- src/config.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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; -- 2.11.0