From d24add10f2d870462fdd1771edbb7a5bb770ec33 Mon Sep 17 00:00:00 2001 From: John Safranek Date: Sun, 1 Nov 2020 18:58:05 -0800 Subject: [PATCH] Nightly Test Fix When performing a fast_mp_montgomery_reduce(), scan-build didn't like that the destination buffer was fully zeroed out. We were only zeroing what was expected to be used. This zeroes only the expected to be used section of the output buffer. --- wolfcrypt/src/integer.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/wolfcrypt/src/integer.c b/wolfcrypt/src/integer.c index 33d741c61..913b66ff5 100644 --- a/wolfcrypt/src/integer.c +++ b/wolfcrypt/src/integer.c @@ -2479,6 +2479,8 @@ int fast_mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho) return MP_MEM; #endif + XMEMSET(W, 0, (n->used * 2 + 1) * sizeof(mp_word)); + /* first we have to get the digits of the input into * an array of double precision words W[...] */ @@ -2496,11 +2498,6 @@ int fast_mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho) for (ix = 0; ix < x->used; ix++) { *_W++ = *tmpx++; } - - /* zero the high words of W[a->used..m->used*2] */ - for (; ix < n->used * 2 + 1; ix++) { - *_W++ = 0; - } } /* now we proceed to zero successive digits