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@milecki.pl>
Tested-by: Kuan-Yi Li <kyli@abysm.org>
Signed-off-by: Petr Štetiar <ynezz@true.cz>
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]);