lib/hcrypto: BN_set_word return false if input 'bn' is NULL

If the input 'bn' is NULL then BN_bin2bn() will allocate and
return a BIGNUM which will then be leaked.   BN_set_word()
would then return true even though it didn't set the word
into a BIGNUM known to the caller.

Change-Id: I6681f548e6bfb330cec009ae7c18e6151016179e
This commit is contained in:
Jeffrey Altman
2022-01-15 23:15:21 -05:00
parent b8450a04a1
commit 19eae8b4a9

View File

@@ -287,6 +287,9 @@ BN_set_word(BIGNUM *bn, unsigned long num)
unsigned long num2;
int i, len;
if (bn == NULL)
return 0;
for (num2 = num, i = 0; num2 > 0; i++)
num2 = num2 >> 8;