Commit 054fd159 authored by Chen Ni's avatar Chen Ni Committed by Richard Weinberger
Browse files

ubifs: add check for crypto_shash_tfm_digest



Add check for the return value of crypto_shash_tfm_digest() and return
the error if it fails in order to catch the error.

Fixes: 817aa094 ("ubifs: support offline signed images")
Signed-off-by: default avatarChen Ni <nichen@iscas.ac.cn>
Reviewed-by: default avatarZhihao Cheng <chengzhihao1@huawei.com>
Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
parent 25e79a7f
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -67,10 +67,13 @@ static int mst_node_check_hash(const struct ubifs_info *c,
{
	u8 calc[UBIFS_MAX_HASH_LEN];
	const void *node = mst;
	int ret;

	crypto_shash_tfm_digest(c->hash_tfm, node + sizeof(struct ubifs_ch),
	ret = crypto_shash_tfm_digest(c->hash_tfm, node + sizeof(struct ubifs_ch),
				UBIFS_MST_NODE_SZ - sizeof(struct ubifs_ch),
				calc);
	if (ret)
		return ret;

	if (ubifs_check_hash(c, expected, calc))
		return -EPERM;