1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 17:38:00 +00:00

Fix aliasing bug in mp_lshift_fixed_into.

I had not considered what would happen if the input and output mp_ints
aliased each other. What happens is that because I wrote the output
starting from the low end, input words would get corrupted before I'd
finished with them. Easily fixed by reversing the order of the loop.
This commit is contained in:
Simon Tatham 2019-01-03 13:08:44 +00:00
parent 2bd76ed88c
commit 0d9ab2f14b

View File

@ -1033,7 +1033,7 @@ void mp_lshift_fixed_into(mp_int *r, mp_int *a, size_t bits)
size_t words = bits / BIGNUM_INT_BITS;
size_t bitoff = bits % BIGNUM_INT_BITS;
for (size_t i = 0; i < r->nw; i++) {
for (size_t i = r->nw; i-- > 0 ;) {
if (i < words) {
r->w[i] = 0;
} else {