зеркало из https://github.com/github/putty.git
Fix 32-bit-only bug in mp_{eq,hs}_integer.
I got the maximum shift count _completely_ wrong when trying to work out whether each word should be compared against part of the input uintmax_t: I measured it in bytes rather than bits _and_ applied it to the wrong type. Ahem.
This commit is contained in:
Родитель
8024b55ea6
Коммит
6fc50d402e
4
mpint.c
4
mpint.c
|
@ -793,7 +793,7 @@ unsigned mp_hs_integer(mp_int *x, uintmax_t n)
|
|||
BignumInt carry = 1;
|
||||
for (size_t i = 0; i < x->nw; i++) {
|
||||
size_t shift = i * BIGNUM_INT_BITS;
|
||||
BignumInt nword = shift < BIGNUM_INT_BYTES ? n >> shift : 0;
|
||||
BignumInt nword = shift < CHAR_BIT*sizeof(n) ? n >> shift : 0;
|
||||
BignumInt dummy_out;
|
||||
BignumADC(dummy_out, carry, x->w[i], ~nword, carry);
|
||||
(void)dummy_out;
|
||||
|
@ -819,7 +819,7 @@ unsigned mp_eq_integer(mp_int *x, uintmax_t n)
|
|||
BignumInt diff = 0;
|
||||
for (size_t i = 0; i < x->nw; i++) {
|
||||
size_t shift = i * BIGNUM_INT_BITS;
|
||||
BignumInt nword = shift < BIGNUM_INT_BYTES ? n >> shift : 0;
|
||||
BignumInt nword = shift < CHAR_BIT*sizeof(n) ? n >> shift : 0;
|
||||
diff |= x->w[i] ^ nword;
|
||||
}
|
||||
return 1 ^ normalise_to_1(diff); /* return 1 if diff _is_ zero */
|
||||
|
|
Загрузка…
Ссылка в новой задаче