From 9814807bd71cba074a23707c32d163b560b551cf Mon Sep 17 00:00:00 2001 From: =?utf8?q?Petr=20=C5=A0tetiar?= Date: Fri, 3 Jan 2020 01:26:50 +0100 Subject: [PATCH] system: sysupgrade: fix possibly misleading error MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Tested-by: Kuan-Yi Li Signed-off-by: Petr Štetiar --- system.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/system.c b/system.c index ffd8f71..0736ec9 100644 --- a/system.c +++ b/system.c @@ -672,6 +672,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]); -- 2.25.1