From ec61e07d18b8efc97ac9e6d6b019708f7607ad1f Mon Sep 17 00:00:00 2001 From: Daniel Pouzzner Date: Tue, 24 Mar 2026 12:07:04 -0500 Subject: [PATCH] wolfcrypt/src/pwdbased.c: in wc_PKCS12_PBKDF_ex(), refactor the "Increment B by 1" loop to avoid bugprone-inc-dec-in-conditions. --- wolfcrypt/src/pwdbased.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/wolfcrypt/src/pwdbased.c b/wolfcrypt/src/pwdbased.c index 90dc8ed339..c2ed5c042f 100644 --- a/wolfcrypt/src/pwdbased.c +++ b/wolfcrypt/src/pwdbased.c @@ -687,9 +687,12 @@ int wc_PKCS12_PBKDF_ex(byte* output, const byte* passwd, int passLen, PKCS12_ByteReverseWords(Bw, Bw, v); #endif /* Increment B by 1. */ - k = nwc; - while ((k-- > 0) && (++Bw[k] == 0)) - ; + for (k = nwc; k > 0; ) { + --k; + ++Bw[k]; + if (Bw[k] != 0) + break; + } #ifndef BIG_ENDIAN_ORDER PKCS12_ByteReverseWords((PKCS12_WORD*)I, (PKCS12_WORD*)I, nBlocks * v);