summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/bn/bn_print.c
diff options
context:
space:
mode:
authorderaadt <>2014-05-29 21:07:43 +0000
committerderaadt <>2014-05-29 21:07:43 +0000
commit642d45ae22413aa8195b105d051ca8896e782c5d (patch)
treed5fe0c330801f3e72c7b588264c6027636db4330 /src/lib/libcrypto/bn/bn_print.c
parentf60b3b3365842d8869513a7e36981671cd726939 (diff)
downloadopenbsd-642d45ae22413aa8195b105d051ca8896e782c5d.tar.gz
openbsd-642d45ae22413aa8195b105d051ca8896e782c5d.tar.bz2
openbsd-642d45ae22413aa8195b105d051ca8896e782c5d.zip
convert 53 malloc(a*b) to reallocarray(NULL, a, b). that is 53
potential integer overflows easily changed into an allocation return of NULL, with errno nicely set if need be. checks for an allocations returning NULL are commonplace, or if the object is dereferenced (quite normal) will result in a nice fault which can be detected & repaired properly. ok tedu
Diffstat (limited to 'src/lib/libcrypto/bn/bn_print.c')
-rw-r--r--src/lib/libcrypto/bn/bn_print.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/lib/libcrypto/bn/bn_print.c b/src/lib/libcrypto/bn/bn_print.c
index 3a0fb25369..ea5fa5c3da 100644
--- a/src/lib/libcrypto/bn/bn_print.c
+++ b/src/lib/libcrypto/bn/bn_print.c
@@ -116,7 +116,7 @@ BN_bn2dec(const BIGNUM *a)
116 */ 116 */
117 i = BN_num_bits(a) * 3; 117 i = BN_num_bits(a) * 3;
118 num = (i / 10 + i / 1000 + 1) + 1; 118 num = (i / 10 + i / 1000 + 1) + 1;
119 bn_data = (BN_ULONG *)malloc((num / BN_DEC_NUM + 1) * sizeof(BN_ULONG)); 119 bn_data = reallocarray(NULL, num / BN_DEC_NUM + 1, sizeof(BN_ULONG));
120 buf = (char *)malloc(num + 3); 120 buf = (char *)malloc(num + 3);
121 if ((buf == NULL) || (bn_data == NULL)) { 121 if ((buf == NULL) || (bn_data == NULL)) {
122 BNerr(BN_F_BN_BN2DEC, ERR_R_MALLOC_FAILURE); 122 BNerr(BN_F_BN_BN2DEC, ERR_R_MALLOC_FAILURE);