ubus: use blobmsg_parse to validate data from network.interface:dump
authorFelix Fietkau <nbd@openwrt.org>
Mon, 30 Jun 2014 16:40:38 +0000 (18:40 +0200)
committerFelix Fietkau <nbd@openwrt.org>
Mon, 30 Jun 2014 16:40:38 +0000 (18:40 +0200)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
ubus.c

diff --git a/ubus.c b/ubus.c
index ec6d84f89c0873f714893c044475cf374b6ede1a..f5fd8c4b7a217767be7499565c60e4194c08a561 100644 (file)
--- a/ubus.c
+++ b/ubus.c
@@ -23,11 +23,12 @@ static struct blob_attr *interfaces = NULL;
 
 static void dump_cb(struct ubus_request *req, int type, struct blob_attr *msg)
 {
+       static const struct blobmsg_policy policy = { "interface", BLOBMSG_TYPE_ARRAY };
        struct blob_attr *cur;
-       unsigned rem = blob_len(msg);
-       __blob_for_each_attr(cur, blob_data(msg), rem)
-               if (!strcmp(blobmsg_name(cur), "interface"))
-                       interfaces = blob_memdup(cur);
+
+       blobmsg_parse(&policy, 1, &cur, blob_data(msg), blob_len(msg));
+       if (cur)
+               interfaces = blob_memdup(cur);
 }
 
 bool