diff options
Diffstat (limited to 'src/lib/libcrypto')
| -rw-r--r-- | src/lib/libcrypto/asn1/x_info.c | 31 |
1 files changed, 9 insertions, 22 deletions
diff --git a/src/lib/libcrypto/asn1/x_info.c b/src/lib/libcrypto/asn1/x_info.c index c476923158..9285e3e289 100644 --- a/src/lib/libcrypto/asn1/x_info.c +++ b/src/lib/libcrypto/asn1/x_info.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: x_info.c,v 1.17 2017/01/29 17:49:22 beck Exp $ */ | 1 | /* $OpenBSD: x_info.c,v 1.18 2020/09/03 17:29:05 tb 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 | * |
| @@ -60,48 +60,35 @@ | |||
| 60 | 60 | ||
| 61 | #include <openssl/asn1.h> | 61 | #include <openssl/asn1.h> |
| 62 | #include <openssl/err.h> | 62 | #include <openssl/err.h> |
| 63 | #include <openssl/evp.h> | ||
| 64 | #include <openssl/x509.h> | 63 | #include <openssl/x509.h> |
| 65 | 64 | ||
| 66 | X509_INFO * | 65 | X509_INFO * |
| 67 | X509_INFO_new(void) | 66 | X509_INFO_new(void) |
| 68 | { | 67 | { |
| 69 | X509_INFO *ret = NULL; | 68 | X509_INFO *ret; |
| 70 | 69 | ||
| 71 | ret = malloc(sizeof(X509_INFO)); | 70 | if ((ret = calloc(1, sizeof(X509_INFO))) == NULL) { |
| 72 | if (ret == NULL) { | ||
| 73 | ASN1error(ERR_R_MALLOC_FAILURE); | 71 | ASN1error(ERR_R_MALLOC_FAILURE); |
| 74 | return (NULL); | 72 | return (NULL); |
| 75 | } | 73 | } |
| 76 | |||
| 77 | ret->enc_cipher.cipher = NULL; | ||
| 78 | ret->enc_len = 0; | ||
| 79 | ret->enc_data = NULL; | ||
| 80 | |||
| 81 | ret->references = 1; | 74 | ret->references = 1; |
| 82 | ret->x509 = NULL; | 75 | |
| 83 | ret->crl = NULL; | 76 | return ret; |
| 84 | ret->x_pkey = NULL; | ||
| 85 | return (ret); | ||
| 86 | } | 77 | } |
| 87 | 78 | ||
| 88 | void | 79 | void |
| 89 | X509_INFO_free(X509_INFO *x) | 80 | X509_INFO_free(X509_INFO *x) |
| 90 | { | 81 | { |
| 91 | int i; | ||
| 92 | |||
| 93 | if (x == NULL) | 82 | if (x == NULL) |
| 94 | return; | 83 | return; |
| 95 | 84 | ||
| 96 | i = CRYPTO_add(&x->references, -1, CRYPTO_LOCK_X509_INFO); | 85 | if (CRYPTO_add(&x->references, -1, CRYPTO_LOCK_X509_INFO) > 0) |
| 97 | if (i > 0) | ||
| 98 | return; | 86 | return; |
| 99 | 87 | ||
| 100 | X509_free(x->x509); | 88 | X509_free(x->x509); |
| 101 | if (x->crl != NULL) | 89 | X509_CRL_free(x->crl); |
| 102 | X509_CRL_free(x->crl); | 90 | X509_PKEY_free(x->x_pkey); |
| 103 | if (x->x_pkey != NULL) | ||
| 104 | X509_PKEY_free(x->x_pkey); | ||
| 105 | free(x->enc_data); | 91 | free(x->enc_data); |
| 92 | |||
| 106 | free(x); | 93 | free(x); |
| 107 | } | 94 | } |
