From 7cb94b9e3f669a62272d07747d346f5393d71c1d Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Mon, 30 Jun 2014 18:40:38 +0200 Subject: [PATCH] ubus: use blobmsg_parse to validate data from network.interface:dump Signed-off-by: Felix Fietkau --- ubus.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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 -- 2.25.1