summaryrefslogtreecommitdiff
path: root/src/lib/libssl/src/crypto/bn/bn_rand.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libssl/src/crypto/bn/bn_rand.c')
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_rand.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/lib/libssl/src/crypto/bn/bn_rand.c b/src/lib/libssl/src/crypto/bn/bn_rand.c
index 943712c15b..21ecbc04ed 100644
--- a/src/lib/libssl/src/crypto/bn/bn_rand.c
+++ b/src/lib/libssl/src/crypto/bn/bn_rand.c
@@ -68,11 +68,17 @@ static int bnrand(int pseudorand, BIGNUM *rnd, int bits, int top, int bottom)
68 int ret=0,bit,bytes,mask; 68 int ret=0,bit,bytes,mask;
69 time_t tim; 69 time_t tim;
70 70
71 if (bits == 0)
72 {
73 BN_zero(rnd);
74 return 1;
75 }
76
71 bytes=(bits+7)/8; 77 bytes=(bits+7)/8;
72 bit=(bits-1)%8; 78 bit=(bits-1)%8;
73 mask=0xff<<bit; 79 mask=0xff<<bit;
74 80
75 buf=(unsigned char *)Malloc(bytes); 81 buf=(unsigned char *)OPENSSL_malloc(bytes);
76 if (buf == NULL) 82 if (buf == NULL)
77 { 83 {
78 BNerr(BN_F_BN_RAND,ERR_R_MALLOC_FAILURE); 84 BNerr(BN_F_BN_RAND,ERR_R_MALLOC_FAILURE);
@@ -120,7 +126,7 @@ err:
120 if (buf != NULL) 126 if (buf != NULL)
121 { 127 {
122 memset(buf,0,bytes); 128 memset(buf,0,bytes);
123 Free(buf); 129 OPENSSL_free(buf);
124 } 130 }
125 return(ret); 131 return(ret);
126 } 132 }