[PATCH 3/6] crypto/gc-pbkdf2: redo unsigned indexes

Paul Eggert <[email protected]>
Newsgroups gmane.comp.lib.gnulib.bugs
Message-ID <[email protected]>
* lib/gc-pbkdf2.c (gc_pbkdf2_prf):
Don’t infloop if upper bound of loop is UINT_MAX.
---
 ChangeLog       | 4 ++++
 lib/gc-pbkdf2.c | 4 ++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 462d4953c4..b86d469fe5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2026-06-26  Paul Eggert  <[email protected]>
 
+	crypto/gc-pbkdf2: redo unsigned indexes
+	* lib/gc-pbkdf2.c (gc_pbkdf2_prf):
+	Don’t infloop if upper bound of loop is UINT_MAX.
+
 	bitset: possibly widen unsigned indexes
 	* lib/bitset/vector.c (vbitset_empty_p, vbitset_not)
 	(vbitset_disjoint_p, vbitset_and, vbitset_and_or)
diff --git a/lib/gc-pbkdf2.c b/lib/gc-pbkdf2.c
index eb97157c24..a6c281ed28 100644
--- a/lib/gc-pbkdf2.c
+++ b/lib/gc-pbkdf2.c
@@ -56,11 +56,11 @@ gc_pbkdf2_prf (gc_prf_func prf, size_t hLen,
   char U[GC_MAX_DIGEST_SIZE];
   char T[GC_MAX_DIGEST_SIZE];
   int rc;
-  for (unsigned int i = 1; i <= l; i++)
+  for (unsigned int i = 0; i++ < l; )
     {
       memset (T, 0, hLen);
 
-      for (unsigned int u = 1; u <= c; u++)
+      for (unsigned int u = 0; u++ < c; )
         {
           if (u == 1)
             {
-- 
2.54.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.