From 8f9c8a12032add2119053300adc474314e77f87f Mon Sep 17 00:00:00 2001 From: Andras Fekete Date: Wed, 8 May 2024 09:52:37 -0400 Subject: [PATCH] Fix infinite loop 'ret' could be set to non-zero inside the loop and the 'cmac->bufferSz' never gets reset causing 'add' to become 0 in the subsequent loop. --- wolfcrypt/src/cmac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wolfcrypt/src/cmac.c b/wolfcrypt/src/cmac.c index 49ab1657c..460d02a07 100644 --- a/wolfcrypt/src/cmac.c +++ b/wolfcrypt/src/cmac.c @@ -211,7 +211,7 @@ int wc_CmacUpdate(Cmac* cmac, const byte* in, word32 inSz) /* Clear CRYPTOCB_UNAVAILABLE return code */ ret = 0; - while (inSz != 0) { + while ((ret == 0) && (inSz != 0)) { word32 add = min(inSz, AES_BLOCK_SIZE - cmac->bufferSz); XMEMCPY(&cmac->buffer[cmac->bufferSz], in, add);