mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-03-22 14:39:24 -05: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:
parent
2bd76ed88c
commit
0d9ab2f14b
2
mpint.c
2
mpint.c
@ -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 words = bits / BIGNUM_INT_BITS;
|
||||||
size_t bitoff = 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) {
|
if (i < words) {
|
||||||
r->w[i] = 0;
|
r->w[i] = 0;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user