[PATCH 4/8] jent: silence ubsan warning about signed overflow

Jussi Kivilinna jussi.kivilinna at iki.fi
Sun Jan 31 17:01:36 CET 2021


* random/jitterentropy-base.c (jent_stuck): Cast 'delta2' values to
'uint64_t' for calculation.
--

Signed-off-by: Jussi Kivilinna <jussi.kivilinna at iki.fi>
---
 random/jitterentropy-base.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/random/jitterentropy-base.c b/random/jitterentropy-base.c
index 32fdea46..ba435e1b 100644
--- a/random/jitterentropy-base.c
+++ b/random/jitterentropy-base.c
@@ -306,7 +306,7 @@ static unsigned int jent_memaccess(struct rand_data *ec, uint64_t loop_cnt)
 static int jent_stuck(struct rand_data *ec, uint64_t current_delta)
 {
 	int64_t delta2 = ec->last_delta - current_delta;
-	int64_t delta3 = delta2 - ec->last_delta2;
+	int64_t delta3 = (uint64_t)delta2 - (uint64_t)ec->last_delta2;
 
 	ec->last_delta = current_delta;
 	ec->last_delta2 = delta2;
-- 
2.27.0




More information about the Gcrypt-devel mailing list