fix network interface object name
authorFelix Fietkau <nbd@openwrt.org>
Wed, 12 Oct 2011 14:07:46 +0000 (16:07 +0200)
committerFelix Fietkau <nbd@openwrt.org>
Wed, 12 Oct 2011 14:07:46 +0000 (16:07 +0200)
ubus.c

diff --git a/ubus.c b/ubus.c
index 8c237c3376f4643a698c6747689ad852b30de093..c9b10e8d7b43a577dc612468600baaecb958d9ff 100644 (file)
--- a/ubus.c
+++ b/ubus.c
@@ -336,13 +336,12 @@ void
 netifd_ubus_add_interface(struct interface *iface)
 {
        struct ubus_object *obj = &iface->ubus;
-       char *name;
+       char *name = NULL;
 
-       name = malloc(strlen(main_object.name) + strlen(iface->name) + 2);
+       asprintf(&name, "%s.interface.%s", main_object.name, iface->name);
        if (!name)
                return;
 
-       sprintf(name, "%s.%s", main_object.name, iface->name);
        obj->name = name;
        obj->type = &iface_object_type;
        obj->methods = iface_object_methods;