From d0dc4033cc0b636914611883caaaf6cddf527223 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 18 Mar 2019 09:30:17 +0100 Subject: [PATCH] heimdal: Fix "assuming signed overflow doesnt occur" error Signed-off-by: Volker Lendecke Reviewed-by: Andreas Schneider --- source4/heimdal/lib/hcrypto/libtommath/bn_mp_rshd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source4/heimdal/lib/hcrypto/libtommath/bn_mp_rshd.c b/source4/heimdal/lib/hcrypto/libtommath/bn_mp_rshd.c index ed13ce59a49..907674c41e4 100644 --- a/source4/heimdal/lib/hcrypto/libtommath/bn_mp_rshd.c +++ b/source4/heimdal/lib/hcrypto/libtommath/bn_mp_rshd.c @@ -18,8 +18,6 @@ /* shift right a certain amount of digits */ void mp_rshd (mp_int * a, int b) { - int x; - /* if b <= 0 then ignore it */ if (b <= 0) { return; @@ -33,6 +31,7 @@ void mp_rshd (mp_int * a, int b) { register mp_digit *bottom, *top; + unsigned x, y; /* shift the digits down */ @@ -52,12 +51,13 @@ void mp_rshd (mp_int * a, int b) /\ | ----> \-------------------/ ----> */ - for (x = 0; x < (a->used - b); x++) { + y = a->used - b; /* a->used>=b checked above */ + for (x = 0; x < y; x++) { *bottom++ = *top++; } /* zero the top digits */ - for (; x < a->used; x++) { + for (; x < (unsigned)a->used; x++) { *bottom++ = 0; } } -- 2.11.4.GIT