Skip to content

Commit 408aa67

Browse files
committed
Merge tag 'v6.16-p2' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
Pull crypto fix from Herbert Xu: "Fix a buffer overflow regression in shash" * tag 'v6.16-p2' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: crypto: shash - Fix buffer overrun in import function
2 parents 1cbf99e + 0a84874 commit 408aa67

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

crypto/shash.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,12 +257,13 @@ static int __crypto_shash_import(struct shash_desc *desc, const void *in,
257257
if (crypto_shash_get_flags(tfm) & CRYPTO_TFM_NEED_KEY)
258258
return -ENOKEY;
259259

260-
plen = crypto_shash_blocksize(tfm) + 1;
261-
descsize = crypto_shash_descsize(tfm);
262260
ss = crypto_shash_statesize(tfm);
263-
buf[descsize - 1] = 0;
264-
if (crypto_shash_block_only(tfm))
261+
if (crypto_shash_block_only(tfm)) {
262+
plen = crypto_shash_blocksize(tfm) + 1;
265263
ss -= plen;
264+
descsize = crypto_shash_descsize(tfm);
265+
buf[descsize - 1] = 0;
266+
}
266267
if (!import) {
267268
memcpy(buf, in, ss);
268269
return 0;

0 commit comments

Comments
 (0)