summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2013-10-15 09:31:33 +0200
committerSteven Barth <steven@midlink.org>2013-10-15 09:31:33 +0200
commitb9ffc26a2d12b9769d1c519d8c851b7c9301e82c (patch)
tree4d7fa5ccc7ffba221f546947a5006017c59234db
parenta9739e68e7697dc833af0473b37a0632f42d107c (diff)
Avoid segfaults when parsing configuration
-rw-r--r--src/config.c8
1 files changed, 7 insertions, 1 deletions
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;