From: Petr Štetiar Date: Fri, 3 Jan 2020 00:26:50 +0000 (+0100) Subject: system: sysupgrade: fix possibly misleading error X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=9814807bd71cba074a23707c32d163b560b551cf;p=project%2Fprocd.git system: sysupgrade: fix possibly misleading error 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 --- 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]);