aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2016-08-22 02:36:36 +0900
committerKazuki Yamaguchi <k@rhe.jp>2016-08-22 02:50:20 +0900
commitbc17c605c348537cdc6b096fa30600a004c87823 (patch)
tree1c711d1e408d41002536aa9f3d2f9bf52dbba085
parentbf932fbd4a2385496fa5e9363bf9280fc6fba0ad (diff)
downloadopenssl-topic/bn-bn2dec-fix.tar.gz
Fix overflow check in BN_bn2dec()topic/bn-bn2dec-fix
Fix an off by one error in the overflow check added by 07bed46f332fc ("Check for errors in BN_bn2dec()").
-rw-r--r--crypto/bn/bn_print.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/crypto/bn/bn_print.c b/crypto/bn/bn_print.c
index f6030ff14c..e5f641b99d 100644
--- a/crypto/bn/bn_print.c
+++ b/crypto/bn/bn_print.c
@@ -92,14 +92,13 @@ char *BN_bn2dec(const BIGNUM *a)
if (BN_is_negative(t))
*p++ = '-';
- i = 0;
while (!BN_is_zero(t)) {
+ if (lp - bn_data >= bn_data_num)
+ goto err;
*lp = BN_div_word(t, BN_DEC_CONV);
if (*lp == (BN_ULONG)-1)
goto err;
lp++;
- if (lp - bn_data >= bn_data_num)
- goto err;
}
lp--;
/*