summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crypto/bio/bss_core.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/crypto/bio/bss_core.c b/crypto/bio/bss_core.c
index de774e2b00..b78b1bedaa 100644
--- a/crypto/bio/bss_core.c
+++ b/crypto/bio/bss_core.c
@@ -48,7 +48,7 @@ static int bio_core_read_ex(BIO *bio, char *data, size_t data_len,
{
BIO_CORE_GLOBALS *bcgbl = get_globals(bio->libctx);
- if (bcgbl->c_bio_read_ex == NULL)
+ if (bcgbl == NULL || bcgbl->c_bio_read_ex == NULL)
return 0;
return bcgbl->c_bio_read_ex(BIO_get_data(bio), data, data_len, bytes_read);
}
@@ -58,7 +58,7 @@ static int bio_core_write_ex(BIO *bio, const char *data, size_t data_len,
{
BIO_CORE_GLOBALS *bcgbl = get_globals(bio->libctx);
- if (bcgbl->c_bio_write_ex == NULL)
+ if (bcgbl == NULL || bcgbl->c_bio_write_ex == NULL)
return 0;
return bcgbl->c_bio_write_ex(BIO_get_data(bio), data, data_len, written);
}
@@ -67,7 +67,7 @@ static long bio_core_ctrl(BIO *bio, int cmd, long num, void *ptr)
{
BIO_CORE_GLOBALS *bcgbl = get_globals(bio->libctx);
- if (bcgbl->c_bio_ctrl == NULL)
+ if (bcgbl == NULL || bcgbl->c_bio_ctrl == NULL)
return -1;
return bcgbl->c_bio_ctrl(BIO_get_data(bio), cmd, num, ptr);
}
@@ -76,7 +76,7 @@ static int bio_core_gets(BIO *bio, char *buf, int size)
{
BIO_CORE_GLOBALS *bcgbl = get_globals(bio->libctx);
- if (bcgbl->c_bio_gets == NULL)
+ if (bcgbl == NULL || bcgbl->c_bio_gets == NULL)
return -1;
return bcgbl->c_bio_gets(BIO_get_data(bio), buf, size);
}
@@ -85,7 +85,7 @@ static int bio_core_puts(BIO *bio, const char *str)
{
BIO_CORE_GLOBALS *bcgbl = get_globals(bio->libctx);
- if (bcgbl->c_bio_puts == NULL)
+ if (bcgbl == NULL || bcgbl->c_bio_puts == NULL)
return -1;
return bcgbl->c_bio_puts(BIO_get_data(bio), str);
}
@@ -101,6 +101,9 @@ static int bio_core_free(BIO *bio)
{
BIO_CORE_GLOBALS *bcgbl = get_globals(bio->libctx);
+ if (bcgbl == NULL)
+ return 0;
+
BIO_set_init(bio, 0);
bcgbl->c_bio_free(BIO_get_data(bio));
@@ -133,7 +136,7 @@ BIO *BIO_new_from_core_bio(OSSL_LIB_CTX *libctx, OSSL_CORE_BIO *corebio)
BIO_CORE_GLOBALS *bcgbl = get_globals(libctx);
/* Check the library context has been initialised with the callbacks */
- if (bcgbl->c_bio_write_ex == NULL && bcgbl->c_bio_read_ex == NULL)
+ if (bcgbl == NULL || (bcgbl->c_bio_write_ex == NULL && bcgbl->c_bio_read_ex == NULL))
return NULL;
if ((outbio = BIO_new_ex(libctx, BIO_s_core())) == NULL)
@@ -151,6 +154,9 @@ int ossl_bio_init_core(OSSL_LIB_CTX *libctx, const OSSL_DISPATCH *fns)
{
BIO_CORE_GLOBALS *bcgbl = get_globals(libctx);
+ if (bcgbl == NULL)
+ return 0;
+
for (; fns->function_id != 0; fns++) {
switch (fns->function_id) {
case OSSL_FUNC_BIO_READ_EX: