diff options
| author | miod <> | 2014-09-26 19:31:09 +0000 |
|---|---|---|
| committer | miod <> | 2014-09-26 19:31:09 +0000 |
| commit | 27b5be2ddfb452443c12042ac5e57ddfd1c81d2c (patch) | |
| tree | 9c8cf22a1890f8abfcfec429814db37c5bbf8ce0 | |
| parent | 7513d3e75acca81202a3f8cea069d3b7838c17ed (diff) | |
| download | openbsd-27b5be2ddfb452443c12042ac5e57ddfd1c81d2c.tar.gz openbsd-27b5be2ddfb452443c12042ac5e57ddfd1c81d2c.tar.bz2 openbsd-27b5be2ddfb452443c12042ac5e57ddfd1c81d2c.zip | |
X509_issuer_and_serial_hash(): do not leak memory if an error occurs during
the first EVP block.
ok tedu@
| -rw-r--r-- | src/lib/libcrypto/x509/x509_cmp.c | 4 | ||||
| -rw-r--r-- | src/lib/libssl/src/crypto/x509/x509_cmp.c | 4 |
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 | ||
| 113 | err: | 114 | err: |
| 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 | ||
| 113 | err: | 114 | err: |
| 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 |
