[OpenWrt-Devel] [PATCH procd 4/4] system: sysupgrade: fix possibly misleading error

Petr Štetiar ynezz at true.cz
Thu Jan 2 19:46:38 EST 2020


Fix possibly misleading error "Firmware image is broken and cannot be
installed" which could be produced by JSON without expected validation
variables, where "Validation script provided invalid input" error message
makes more sense.

Cc: Rafał Miłecki <rafal at milecki.pl>
Signed-off-by: Petr Štetiar <ynezz at true.cz>
---
 system.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/system.c b/system.c
index f0198a5b20b8..f4b75276aaf1 100644
--- a/system.c
+++ b/system.c
@@ -671,6 +671,12 @@ static int sysupgrade(struct ubus_context *ctx, struct ubus_object *obj,
 
 	blobmsg_parse(validation_policy, __VALIDATION_MAX, validation, blob_data(b.head), blob_len(b.head));
 
+	if (!validation[VALIDATION_VALID] || !validation[VALIDATION_FORCEABLE] ||
+	    !validation[VALIDATION_ALLOW_BACKUP]) {
+		sysupgrade_error(ctx, req, "Validation script provided invalid input");
+		return UBUS_STATUS_INVALID_ARGUMENT;
+	}
+
 	valid = validation[VALIDATION_VALID] && blobmsg_get_bool(validation[VALIDATION_VALID]);
 	forceable = validation[VALIDATION_FORCEABLE] && blobmsg_get_bool(validation[VALIDATION_FORCEABLE]);
 	allow_backup = validation[VALIDATION_ALLOW_BACKUP] && blobmsg_get_bool(validation[VALIDATION_ALLOW_BACKUP]);

_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list