Fix off-by-one bug in mpi_cmp() which could cause it to read past the

end of the buffer.
This commit is contained in:
Dag-Erling Smørgrav 2014-12-30 16:35:13 +00:00 committed by des
parent 43b870dc83
commit 1c024928f9

View file

@ -52,7 +52,7 @@ mpi_cmp_abs(cryb_mpi *X, cryb_mpi *Y)
if (X->msb < Y->msb)
return (-1);
/* no luck, compare word by word */
for (i = (X->msb + 31) / 32; i >= 0; --i) {
for (i = X->msb / 32; i >= 0; --i) {
if (X->words[i] > Y->words[i])
return (1);
if (X->words[i] < Y->words[i])