Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-9]: src/lib/libcrypt Pull up following revision(s) (requested by ...



details:   https://anonhg.NetBSD.org/src/rev/93dc6a0a383a
branches:  netbsd-9
changeset: 1002414:93dc6a0a383a
user:      martin <martin%NetBSD.org@localhost>
date:      Sun Oct 31 14:47:04 2021 +0000

description:
Pull up following revision(s) (requested by nia in ticket #1370):

        lib/libcrypt/crypt-sha1.c: revision 1.10

libcrypt: Fix a floating point exception when a low number of HMAC-SHA1
iterations are specified.

diffstat:

 lib/libcrypt/crypt-sha1.c |  17 ++++-------------
 1 files changed, 4 insertions(+), 13 deletions(-)

diffs (45 lines):

diff -r f1a396d3b7ae -r 93dc6a0a383a lib/libcrypt/crypt-sha1.c
--- a/lib/libcrypt/crypt-sha1.c Mon Oct 25 18:11:55 2021 +0000
+++ b/lib/libcrypt/crypt-sha1.c Sun Oct 31 14:47:04 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: crypt-sha1.c,v 1.8 2013/08/28 17:47:07 riastradh Exp $ */
+/* $NetBSD: crypt-sha1.c,v 1.8.28.1 2021/10/31 14:47:04 martin Exp $ */
 
 /*
  * Copyright (c) 2004, Juniper Networks, Inc.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 #if !defined(lint)
-__RCSID("$NetBSD: crypt-sha1.c,v 1.8 2013/08/28 17:47:07 riastradh Exp $");
+__RCSID("$NetBSD: crypt-sha1.c,v 1.8.28.1 2021/10/31 14:47:04 martin Exp $");
 #endif /* not lint */
 
 #include <stdlib.h>
@@ -71,24 +71,15 @@
 unsigned int
 __crypt_sha1_iterations (unsigned int hint)
 {
-    static int once = 1;
-
     /*
      * We treat CRYPT_SHA1_ITERATIONS as a hint.
      * Make it harder for someone to pre-compute hashes for a
      * dictionary attack by not using the same iteration count for
      * every entry.
      */
-
-    if (once) {
-       int pid = getpid();
-       
-       srandom(time(NULL) ^ (pid * pid));
-       once = 0;
-    }
-    if (hint == 0)
+    if (hint < 4)
        hint = CRYPT_SHA1_ITERATIONS;
-    return hint - (random() % (hint / 4));
+    return hint - arc4random_uniform(hint / 4);
 }
 
 /*



Home | Main Index | Thread Index | Old Index