add validation for hotplug commands
authorFelix Fietkau <nbd@openwrt.org>
Tue, 12 Feb 2013 16:25:56 +0000 (17:25 +0100)
committerFelix Fietkau <nbd@openwrt.org>
Tue, 12 Feb 2013 16:25:56 +0000 (17:25 +0100)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
hotplug-rule.c

index a2d88927b1abe32be557b13f57960bc74b914567..7508b1dd1a70b175492bceddfec1d8f789d2c5d9 100644 (file)
@@ -379,6 +379,11 @@ static int cmd_process_strings(struct blob_attr *attr, struct blob_attr *msg)
                if (args++ < 0)
                        continue;
 
+               if (blobmsg_type(cur) != BLOBMSG_TYPE_STRING) {
+                       rule_error(attr, "Invalid argument in command");
+                       return -1;
+               }
+
                cmd_add_string(blobmsg_data(cur), msg);
        }
 
@@ -398,7 +403,10 @@ static int __rule_process_cmd(struct blob_attr *cur, struct blob_attr *msg)
                return ret;
 
        name = blobmsg_data(blobmsg_data(cur));
-       cmd_process_strings(cur, msg);
+       ret = cmd_process_strings(cur, msg);
+       if (ret)
+               return ret;
+
        rule_handle_command(name, blob_data(b.head));
 
        return 0;