From: Felix Fietkau Date: Mon, 30 Jun 2014 16:40:38 +0000 (+0200) Subject: ubus: use blobmsg_parse to validate data from network.interface:dump X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=7cb94b9e3f669a62272d07747d346f5393d71c1d;p=oweals%2Ffirewall3.git ubus: use blobmsg_parse to validate data from network.interface:dump Signed-off-by: Felix Fietkau --- diff --git a/ubus.c b/ubus.c index ec6d84f..f5fd8c4 100644 --- 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