]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-otp: Use for-loop instead while
authorAki Tuomi <aki.tuomi@open-xchange.com>
Thu, 13 Aug 2020 08:41:23 +0000 (11:41 +0300)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Fri, 11 Sep 2020 07:07:20 +0000 (07:07 +0000)
Avoids unsigned integer wrap

src/lib-otp/otp-hash.c

index 0ad90bece4022f9851f6bc2e2209a18eb5bd7fab..c1b6f72c2bcf1a3ba295c863060353a034329d9a 100644 (file)
@@ -147,7 +147,7 @@ void otp_hash(unsigned int algo, const char *seed, const char *passphrase,
        digest_update(&ctx, passphrase, strlen(passphrase));
        digest_otp_final(&ctx, result);
 
-       while (step-- > 0) {
+       for (unsigned int i = 0; i < step; i++) {
                digest_init(&ctx, algo);
                digest_update(&ctx, result, OTP_HASH_SIZE);
                digest_otp_final(&ctx, result);