proto-shell: fix updating settings, only issue ifup event after configuration has...
[project/netifd.git] / ubus.c
diff --git a/ubus.c b/ubus.c
index 8c237c3..ba9fb9e 100644 (file)
--- a/ubus.c
+++ b/ubus.c
@@ -1,4 +1,7 @@
+#define _GNU_SOURCE
+
 #include <string.h>
+#include <stdio.h>
 
 #include "netifd.h"
 #include "interface.h"
@@ -336,13 +339,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;