1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-25 01:02:24 +00:00

bignum_set_bit: Don't abort if asked to clear an inaccessible bit

All those bits are clear anyway.

Bug found with the help of afl-fuzz.
This commit is contained in:
Ben Harris 2015-10-11 09:27:55 +01:00
parent c0e19ca19d
commit 4f34059902

View File

@ -1311,9 +1311,9 @@ int bignum_bit(Bignum bn, int i)
*/ */
void bignum_set_bit(Bignum bn, int bitnum, int value) void bignum_set_bit(Bignum bn, int bitnum, int value)
{ {
if (bitnum < 0 || bitnum >= (int)(BIGNUM_INT_BITS * bn[0])) if (bitnum < 0 || bitnum >= (int)(BIGNUM_INT_BITS * bn[0])) {
abort(); /* beyond the end */ if (value) abort(); /* beyond the end */
else { } else {
int v = bitnum / BIGNUM_INT_BITS + 1; int v = bitnum / BIGNUM_INT_BITS + 1;
BignumInt mask = (BignumInt)1 << (bitnum % BIGNUM_INT_BITS); BignumInt mask = (BignumInt)1 << (bitnum % BIGNUM_INT_BITS);
if (value) if (value)