Check for invalid divisors in BN_div.

This commit is contained in:
Adam Langley 2014-06-20 12:00:00 -07:00
parent 1258b6a756
commit 6aea58d0ea

View File

@ -122,8 +122,9 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
int no_branch = 0; int no_branch = 0;
/* Invalid zero-padding would have particularly bad consequences /* Invalid zero-padding would have particularly bad consequences
* in the case of 'num'. */ * so don't just rely on bn_check_top() here */
if (num->top > 0 && num->d[num->top - 1] == 0) { if ((num->top > 0 && num->d[num->top - 1] == 0) ||
(divisor->top > 0 && divisor->d[divisor->top - 1] == 0)) {
OPENSSL_PUT_ERROR(BN, BN_div, BN_R_NOT_INITIALIZED); OPENSSL_PUT_ERROR(BN, BN_div, BN_R_NOT_INITIALIZED);
return 0; return 0;
} }