hotplug: add extra validation for commands
authorFelix Fietkau <nbd@openwrt.org>
Wed, 13 Feb 2013 16:11:30 +0000 (17:11 +0100)
committerFelix Fietkau <nbd@openwrt.org>
Wed, 13 Feb 2013 16:11:32 +0000 (17:11 +0100)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
hotplug-rule.c

index 7e9c16adff7c25dd1f6a9f8bebddbdd9e58a1e64..b157fcd19bca926ec11a7215eaaa394afa3397b8 100644 (file)
@@ -399,6 +399,12 @@ static int __rule_process_cmd(struct blob_attr *cur, struct blob_attr *msg)
        bool found;
        int ret;
 
+       if (blobmsg_type(cur) != BLOBMSG_TYPE_ARRAY ||
+           blobmsg_type(blobmsg_data(cur)) != BLOBMSG_TYPE_STRING) {
+               rule_error(cur, "Unexpected element type");
+               return -1;
+       }
+
        ret = __rule_process_type(cur, msg, cmd, ARRAY_SIZE(cmd), &found);
        if (found)
                return ret;