summaryrefslogtreecommitdiffstats
path: root/crypto/encode_decode/decoder_lib.c
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2021-05-15 10:27:09 +0100
committerMatt Caswell <matt@openssl.org>2021-05-18 15:30:25 +0100
commit40692ed7c80ae3bb6c92c674fb90a5e15d81052d (patch)
treee21057e3572c5d67325487563e0a940ebc4d0d13 /crypto/encode_decode/decoder_lib.c
parent9be5f9a8698b0d902ef1281716eda73a4d8478ed (diff)
Better error messages if there are no encoders/decoders/store loaders
If you don't have the base or default providers loaded and therefore there are no encoders/decoders or store loaders then the error messages can be cryptic. We provide better hints about how to fix the problem. Fixes #13798 Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15306)
Diffstat (limited to 'crypto/encode_decode/decoder_lib.c')
-rw-r--r--crypto/encode_decode/decoder_lib.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/crypto/encode_decode/decoder_lib.c b/crypto/encode_decode/decoder_lib.c
index 8a5082c441..c7eac0eddd 100644
--- a/crypto/encode_decode/decoder_lib.c
+++ b/crypto/encode_decode/decoder_lib.c
@@ -48,6 +48,14 @@ int OSSL_DECODER_from_bio(OSSL_DECODER_CTX *ctx, BIO *in)
int ok = 0;
BIO *new_bio = NULL;
+ if (OSSL_DECODER_CTX_get_num_decoders(ctx) == 0) {
+ ERR_raise_data(ERR_LIB_OSSL_DECODER, OSSL_DECODER_R_DECODER_NOT_FOUND,
+ "No decoders were found. For standard decoders you need "
+ "at least one of the default or base providers "
+ "available. Did you forget to load them?");
+ return 0;
+ }
+
if (BIO_tell(in) < 0) {
new_bio = BIO_new(BIO_f_readbuffer());
if (new_bio == NULL)