diff options
author | Felix Fietkau <nbd@openwrt.org> | 2014-06-30 18:40:38 +0200 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2014-06-30 18:40:38 +0200 |
commit | 7cb94b9e3f669a62272d07747d346f5393d71c1d (patch) | |
tree | b2c7708a50ae87c8eb05126eb8321306ebab510b | |
parent | b99104d3ab99077cdce312e1c0a8e605844b525c (diff) | |
download | firewall3-7cb94b9e3f669a62272d07747d346f5393d71c1d.tar.gz |
ubus: use blobmsg_parse to validate data from network.interface:dump
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
-rw-r--r-- | ubus.c | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -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 |