diff options
author | Theo Buehler <tb@cvs.openbsd.org> | 2021-11-05 07:25:37 +0000 |
---|---|---|
committer | Theo Buehler <tb@cvs.openbsd.org> | 2021-11-05 07:25:37 +0000 |
commit | 1003eb3d6febdcd9843f672de5540a43e7d2f264 (patch) | |
tree | 2372b73a8e0d8f2b423358a1f83adea89eafb86e /lib | |
parent | 2ff782d0566a59e02dc565575bb6e967d6685d88 (diff) |
Garbage collect xobj->data.{ptr,pkey}
Both these are essentially unused. Remove the last use of data.ptr
by initializing and copying the X509_OBJECT using memset() and
struct assignment in X509_STORE_CTX_get_subject_by_name() and add
a missing error check for X509_OBJECT_up_ref_count() while there.
ok beck
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libcrypto/x509/x509_lcl.h | 2 | ||||
-rw-r--r-- | lib/libcrypto/x509/x509_lu.c | 12 |
2 files changed, 6 insertions, 8 deletions
diff --git a/lib/libcrypto/x509/x509_lcl.h b/lib/libcrypto/x509/x509_lcl.h index 804fff48fc3..e1894e55239 100644 --- a/lib/libcrypto/x509/x509_lcl.h +++ b/lib/libcrypto/x509/x509_lcl.h @@ -246,10 +246,8 @@ struct x509_object_st { /* one of the above types */ int type; union { - char *ptr; X509 *x509; X509_CRL *crl; - EVP_PKEY *pkey; } data; } /* X509_OBJECT */; diff --git a/lib/libcrypto/x509/x509_lu.c b/lib/libcrypto/x509/x509_lu.c index d4ea5276628..8290f896577 100644 --- a/lib/libcrypto/x509/x509_lu.c +++ b/lib/libcrypto/x509/x509_lu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_lu.c,v 1.37 2021/11/01 17:20:50 tb Exp $ */ +/* $OpenBSD: x509_lu.c,v 1.38 2021/11/05 07:25:36 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -57,6 +57,7 @@ */ #include <stdio.h> +#include <string.h> #include <openssl/err.h> #include <openssl/lhash.h> @@ -349,8 +350,7 @@ X509_STORE_CTX_get_by_subject(X509_STORE_CTX *vs, X509_LOOKUP_TYPE type, if (ctx == NULL) return 0; - stmp.type = 0; - stmp.data.ptr = NULL; + memset(&stmp, 0, sizeof(stmp)); CRYPTO_w_lock(CRYPTO_LOCK_X509_STORE); tmp = X509_OBJECT_retrieve_by_subject(ctx->objs, type, name); @@ -368,10 +368,10 @@ X509_STORE_CTX_get_by_subject(X509_STORE_CTX *vs, X509_LOOKUP_TYPE type, return 0; } - ret->type = tmp->type; - ret->data.ptr = tmp->data.ptr; + if (!X509_OBJECT_up_ref_count(tmp)) + return 0; - X509_OBJECT_up_ref_count(ret); + *ret = *tmp; return 1; } |