summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormiod <>2014-09-26 19:31:09 +0000
committermiod <>2014-09-26 19:31:09 +0000
commitb56e3b6f404550122f43dc8bbb2d822aedb0d716 (patch)
tree9c8cf22a1890f8abfcfec429814db37c5bbf8ce0 /src
parent95519954bb32998ee415d159b5b8ca1be9e0d827 (diff)
downloadopenbsd-b56e3b6f404550122f43dc8bbb2d822aedb0d716.tar.gz
openbsd-b56e3b6f404550122f43dc8bbb2d822aedb0d716.tar.bz2
openbsd-b56e3b6f404550122f43dc8bbb2d822aedb0d716.zip
X509_issuer_and_serial_hash(): do not leak memory if an error occurs during
the first EVP block. ok tedu@
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/x509/x509_cmp.c4
-rw-r--r--src/lib/libssl/src/crypto/x509/x509_cmp.c4
2 files changed, 6 insertions, 2 deletions
diff --git a/src/lib/libcrypto/x509/x509_cmp.c b/src/lib/libcrypto/x509/x509_cmp.c
index e783683f3a..030e29bde7 100644
--- a/src/lib/libcrypto/x509/x509_cmp.c
+++ b/src/lib/libcrypto/x509/x509_cmp.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_cmp.c,v 1.24 2014/07/13 11:15:54 miod Exp $ */ 1/* $OpenBSD: x509_cmp.c,v 1.25 2014/09/26 19:31:09 miod Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -100,6 +100,7 @@ X509_issuer_and_serial_hash(X509 *a)
100 if (!EVP_DigestUpdate(&ctx, (unsigned char *)f, strlen(f))) 100 if (!EVP_DigestUpdate(&ctx, (unsigned char *)f, strlen(f)))
101 goto err; 101 goto err;
102 free(f); 102 free(f);
103 f = NULL;
103 if (!EVP_DigestUpdate(&ctx, 104 if (!EVP_DigestUpdate(&ctx,
104 (unsigned char *)a->cert_info->serialNumber->data, 105 (unsigned char *)a->cert_info->serialNumber->data,
105 (unsigned long)a->cert_info->serialNumber->length)) 106 (unsigned long)a->cert_info->serialNumber->length))
@@ -112,6 +113,7 @@ X509_issuer_and_serial_hash(X509 *a)
112 113
113err: 114err:
114 EVP_MD_CTX_cleanup(&ctx); 115 EVP_MD_CTX_cleanup(&ctx);
116 free(f);
115 return (ret); 117 return (ret);
116} 118}
117#endif 119#endif
diff --git a/src/lib/libssl/src/crypto/x509/x509_cmp.c b/src/lib/libssl/src/crypto/x509/x509_cmp.c
index e783683f3a..030e29bde7 100644
--- a/src/lib/libssl/src/crypto/x509/x509_cmp.c
+++ b/src/lib/libssl/src/crypto/x509/x509_cmp.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_cmp.c,v 1.24 2014/07/13 11:15:54 miod Exp $ */ 1/* $OpenBSD: x509_cmp.c,v 1.25 2014/09/26 19:31:09 miod Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -100,6 +100,7 @@ X509_issuer_and_serial_hash(X509 *a)
100 if (!EVP_DigestUpdate(&ctx, (unsigned char *)f, strlen(f))) 100 if (!EVP_DigestUpdate(&ctx, (unsigned char *)f, strlen(f)))
101 goto err; 101 goto err;
102 free(f); 102 free(f);
103 f = NULL;
103 if (!EVP_DigestUpdate(&ctx, 104 if (!EVP_DigestUpdate(&ctx,
104 (unsigned char *)a->cert_info->serialNumber->data, 105 (unsigned char *)a->cert_info->serialNumber->data,
105 (unsigned long)a->cert_info->serialNumber->length)) 106 (unsigned long)a->cert_info->serialNumber->length))
@@ -112,6 +113,7 @@ X509_issuer_and_serial_hash(X509 *a)
112 113
113err: 114err:
114 EVP_MD_CTX_cleanup(&ctx); 115 EVP_MD_CTX_cleanup(&ctx);
116 free(f);
115 return (ret); 117 return (ret);
116} 118}
117#endif 119#endif