Fix illegal memory access
[project/odhcpd.git] / src / config.c
index e33c855..5d29173 100644 (file)
@@ -284,10 +284,12 @@ int config_parse_interface(void *data, size_t len, const char *name, bool overwr
        else if ((c = tb[IFACE_ATTR_NETWORKID]))
                ifname = blobmsg_get_string(c);
 
-       if (!ifname)
+       if (!iface->ifname[0] && !ifname)
                return -1;
 
-       strncpy(iface->ifname, ifname, sizeof(iface->ifname) - 1);
+       if (ifname)
+               strncpy(iface->ifname, ifname, sizeof(iface->ifname) - 1);
+
        iface->inuse = true;
 
        if (overwrite)