From 1e30b36946b45e76ba99564ca48a6b246c528dd8 Mon Sep 17 00:00:00 2001 From: tb Date: Tue, 9 Apr 2024 18:12:11 +0000 Subject: [PATCH] whirlpool_test: avoid calling arc4random_uniform(0) This causes a SIGFPE on solaris Fixes https://github.com/libressl/portable/issues/1042 --- regress/lib/libcrypto/whirlpool/whirlpool_test.c | 6 ++++-- 1 file 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 * @@ -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) -- 2.20.1