aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/bn/bn_lib.c
diff options
context:
space:
mode:
authorBodo Möller <bodo@openssl.org>2002-08-02 18:23:55 +0000
committerBodo Möller <bodo@openssl.org>2002-08-02 18:23:55 +0000
commit33d4e690ccd7cfc673af89d299e815ed35cc844a (patch)
tree7c7f81176bc9d3c97197565c8f4475222afb87e4 /crypto/bn/bn_lib.c
parent848c849584c2c6de3373516a762fa4279d89a8c3 (diff)
downloadopenssl-33d4e690ccd7cfc673af89d299e815ed35cc844a.tar.gz
fix bn_expand2
Diffstat (limited to 'crypto/bn/bn_lib.c')
-rw-r--r--crypto/bn/bn_lib.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/crypto/bn/bn_lib.c b/crypto/bn/bn_lib.c
index 77a9e32254..60e3c680bc 100644
--- a/crypto/bn/bn_lib.c
+++ b/crypto/bn/bn_lib.c
@@ -425,7 +425,7 @@ BIGNUM *bn_dup_expand(const BIGNUM *b, int words)
/* This is an internal function that should not be used in applications.
* It ensures that 'b' has enough room for a 'words' word number
- * and initialises the unused part of b->d with leading zeros.
+ * and initialises any unused part of b->d with leading zeros.
* It is mostly used by the various BIGNUM routines. If there is an error,
* NULL is returned. If not, 'b' is returned. */
@@ -450,15 +450,18 @@ BIGNUM *bn_expand2(BIGNUM *b, int words)
}
/* NB: bn_wexpand() calls this only if the BIGNUM really has to grow */
- A = &(b->d[b->top]);
- for (i=(words - b->top)>>3; i>0; i--,A+=8)
+ if ((b != NULL) && (b->top < b->dmax))
{
- A[0]=0; A[1]=0; A[2]=0; A[3]=0;
- A[4]=0; A[5]=0; A[6]=0; A[7]=0;
+ A = &(b->d[b->top]);
+ for (i=(words - b->top)>>3; i>0; i--,A+=8)
+ {
+ A[0]=0; A[1]=0; A[2]=0; A[3]=0;
+ A[4]=0; A[5]=0; A[6]=0; A[7]=0;
+ }
+ for (i=(words - b->top)&7; i>0; i--,A++)
+ A[0]=0;
}
- for (i=(words - b->top)&7; i>0; i--,A++)
- A[0]=0;
-
+
return b;
}