提交 c4db1a8b 编写于 作者: G Geoff Thorpe

This fixes a couple of cases where an inconsistent BIGNUM could be passed as

input to a function.
上级 f7939fcd
...@@ -348,11 +348,16 @@ X) -> 0x%08X\n", ...@@ -348,11 +348,16 @@ X) -> 0x%08X\n",
l0=bn_mul_words(tmp->d,sdiv->d,div_n,q); l0=bn_mul_words(tmp->d,sdiv->d,div_n,q);
wnum.d--; wnum.top++; wnum.d--; wnum.top++;
tmp->d[div_n]=l0; tmp->d[div_n]=l0;
/* XXX: Couldn't we replace this with;
* tmp->top = div_n;
* bn_fix_top(tmp);
*/
for (j=div_n+1; j>0; j--) for (j=div_n+1; j>0; j--)
if (tmp->d[j-1]) break; if (tmp->d[j-1]) break;
tmp->top=j; tmp->top=j;
j=wnum.top; j=wnum.top;
bn_fix_top(&wnum);
if (!BN_sub(&wnum,&wnum,tmp)) goto err; if (!BN_sub(&wnum,&wnum,tmp)) goto err;
snum->top=snum->top+wnum.top-j; snum->top=snum->top+wnum.top-j;
...@@ -373,6 +378,7 @@ X) -> 0x%08X\n", ...@@ -373,6 +378,7 @@ X) -> 0x%08X\n",
* BN_rshift() will overwrite it. * BN_rshift() will overwrite it.
*/ */
int neg = num->neg; int neg = num->neg;
bn_fix_top(snum);
BN_rshift(rm,snum,norm_shift); BN_rshift(rm,snum,norm_shift);
if (!BN_is_zero(rm)) if (!BN_is_zero(rm))
rm->neg = neg; rm->neg = neg;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册