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:
@@ -287,6 +287,9 @@ BN_set_word(BIGNUM *bn, unsigned long num)
|
|||||||
unsigned long num2;
|
unsigned long num2;
|
||||||
int i, len;
|
int i, len;
|
||||||
|
|
||||||
|
if (bn == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
for (num2 = num, i = 0; num2 > 0; i++)
|
for (num2 = num, i = 0; num2 > 0; i++)
|
||||||
num2 = num2 >> 8;
|
num2 = num2 >> 8;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user