summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/pem/pem_seal.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/pem/pem_seal.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/pem/pem_seal.c')
-rw-r--r--src/lib/libcrypto/pem/pem_seal.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/lib/libcrypto/pem/pem_seal.c b/src/lib/libcrypto/pem/pem_seal.c
index 92b70157cd..a7b9379223 100644
--- a/src/lib/libcrypto/pem/pem_seal.c
+++ b/src/lib/libcrypto/pem/pem_seal.c
@@ -85,7 +85,7 @@ PEM_SealInit(PEM_ENCODE_SEAL_CTX *ctx, EVP_CIPHER *type, EVP_MD *md_type,
85 if (j > max) 85 if (j > max)
86 max = j; 86 max = j;
87 } 87 }
88 s = (char *)malloc(max*2); 88 s = (char *)reallocarray(NULL, max, 2);
89 if (s == NULL) { 89 if (s == NULL) {
90 PEMerr(PEM_F_PEM_SEALINIT, ERR_R_MALLOC_FAILURE); 90 PEMerr(PEM_F_PEM_SEALINIT, ERR_R_MALLOC_FAILURE);
91 goto err; 91 goto err;
@@ -159,7 +159,7 @@ PEM_SealFinal(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *sig, int *sigl,
159 i = RSA_size(priv->pkey.rsa); 159 i = RSA_size(priv->pkey.rsa);
160 if (i < 100) 160 if (i < 100)
161 i = 100; 161 i = 100;
162 s = (unsigned char *)malloc(i*2); 162 s = reallocarray(NULL, i, 2);
163 if (s == NULL) { 163 if (s == NULL) {
164 PEMerr(PEM_F_PEM_SEALFINAL, ERR_R_MALLOC_FAILURE); 164 PEMerr(PEM_F_PEM_SEALFINAL, ERR_R_MALLOC_FAILURE);
165 goto err; 165 goto err;