summaryrefslogtreecommitdiffstats
path: root/providers/implementations/storemgmt
diff options
context:
space:
mode:
authorPauli <ppzgs1@gmail.com>2021-03-04 13:53:53 +1000
committerPauli <ppzgs1@gmail.com>2021-03-11 09:25:57 +1000
commit141cc94e44db93cded4ce3f0d97b9b5b928f43f2 (patch)
tree111a6e47c2a86347a6d969d00844a5b2dc8a5805 /providers/implementations/storemgmt
parent7a45d51ce3268d16409405b9d54d7b4bb77a7fc3 (diff)
Add a real type for OSSL_CORE_BIO which is distinct from and not castable to BIO
Providers (particularly the FIPS provider) needs access to BIOs from libcrypto. Libcrypto is allowed to change the internal format of the BIO structure and it is still expected to work with providers that were already built. This means that the libcrypto BIO must be distinct from and not castable to the provider side OSSL_CORE_BIO. Unfortunately, this requirement was broken in both directions. This fixes things by forcing the two to be different and any casts break loudly. Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14419)
Diffstat (limited to 'providers/implementations/storemgmt')
-rw-r--r--providers/implementations/storemgmt/file_store_der2obj.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/providers/implementations/storemgmt/file_store_der2obj.c b/providers/implementations/storemgmt/file_store_der2obj.c
index 74a18eb70b..d34e90540d 100644
--- a/providers/implementations/storemgmt/file_store_der2obj.c
+++ b/providers/implementations/storemgmt/file_store_der2obj.c
@@ -85,10 +85,13 @@ static int der2obj_decode(void *provctx, OSSL_CORE_BIO *cin, int selection,
* We're called from file_store.c, so we know that OSSL_CORE_BIO is a
* BIO in this case.
*/
- BIO *in = (BIO *)cin;
+ BIO *in = bio_new_from_core_bio(provctx, cin);
BUF_MEM *mem = NULL;
int err, ok;
+ if (in == NULL)
+ return 0;
+
ERR_set_mark();
ok = (asn1_d2i_read_bio(in, &mem) >= 0);
/*
@@ -117,6 +120,7 @@ static int der2obj_decode(void *provctx, OSSL_CORE_BIO *cin, int selection,
OPENSSL_free(mem->data);
OPENSSL_free(mem);
}
+ BIO_free(in);
return ok;
}