crypto: testmgr - fix out of bound read in __test_aead()
authorJerome Marchand <jmarchan@redhat.com>
Wed, 3 Feb 2016 12:58:12 +0000 (13:58 +0100)
committerSasha Levin <alexander.levin@verizon.com>
Tue, 13 Jun 2017 13:29:18 +0000 (09:29 -0400)
commitf364181f7aa2e6dc6ae837da02c7c7811023c2cd
treeec7ba19181c0823eaf84a42f2dd3faf566e6b4a2
parent9800a9a4b17ae1ede8cd0d3fbd55183fe5653406
crypto: testmgr - fix out of bound read in __test_aead()

[ Upstream commit abfa7f4357e3640fdee87dfc276fd0f379fb5ae6 ]

__test_aead() reads MAX_IVLEN bytes from template[i].iv, but the
actual length of the initialisation vector can be shorter.
The length of the IV is already calculated earlier in the
function. Let's just reuses that. Also the IV length is currently
calculated several time for no reason. Let's fix that too.
This fix an out-of-bound error detected by KASan.

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
crypto/testmgr.c