summaryrefslogtreecommitdiff
path: root/regress
diff options
context:
space:
mode:
authorTheo Buehler <tb@cvs.openbsd.org>2024-04-09 18:12:12 +0000
committerTheo Buehler <tb@cvs.openbsd.org>2024-04-09 18:12:12 +0000
commit272026603fbe4c3b7bb13897d2c7ca1254ab746c (patch)
treec9b77ae3847968dfff69a13381d56e98a761f377 /regress
parent4fef53a9fb0d55da9da86ac9bb1c07efa0a5552d (diff)
whirlpool_test: avoid calling arc4random_uniform(0)
This causes a SIGFPE on solaris Fixes https://github.com/libressl/portable/issues/1042
Diffstat (limited to 'regress')
-rw-r--r--regress/lib/libcrypto/whirlpool/whirlpool_test.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/regress/lib/libcrypto/whirlpool/whirlpool_test.c b/regress/lib/libcrypto/whirlpool/whirlpool_test.c
index 940531d49a8..809edbba164 100644
--- a/regress/lib/libcrypto/whirlpool/whirlpool_test.c
+++ b/regress/lib/libcrypto/whirlpool/whirlpool_test.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: whirlpool_test.c,v 1.2 2024/04/09 18:08:43 tb Exp $ */
+/* $OpenBSD: whirlpool_test.c,v 1.3 2024/04/09 18:12:11 tb Exp $ */
/*
* Copyright (c) 2024 Joshua Sing <joshua@joshuasing.dev>
*
@@ -192,7 +192,9 @@ whirlpool_test(void)
}
for (l = 0; l < wt->in_len;) {
- in_len = arc4random_uniform(wt->in_len / 2);
+ in_len = 1;
+ if (wt->in_len > 1)
+ in_len = arc4random_uniform(wt->in_len / 2);
if (in_len < 1)
in_len = 1;
if (in_len > wt->in_len - l)