summaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorTomas Mraz <tomas@openssl.org>2021-05-25 09:59:06 +0200
committerTomas Mraz <tomas@openssl.org>2021-05-26 13:04:38 +0200
commit4d2d4b4bc1a8515fa5c17906393458a7beef5422 (patch)
treed4f68a7d98323b17243863f3d73312666e9b724c /crypto
parentAdd negative test cases for PEM_read_bio_PrivateKey (diff)
downloadopenssl-4d2d4b4bc1a8515fa5c17906393458a7beef5422.tar.xz
openssl-4d2d4b4bc1a8515fa5c17906393458a7beef5422.zip
OSSL_DECODER_from_bio: Report an unsupported error when there is none
When nothing was decoded and there is no error on the stack report something. Fixes #15442 Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15441)
Diffstat (limited to 'crypto')
-rw-r--r--crypto/encode_decode/decoder_lib.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/crypto/encode_decode/decoder_lib.c b/crypto/encode_decode/decoder_lib.c
index c7eac0eddd..022c1d56e2 100644
--- a/crypto/encode_decode/decoder_lib.c
+++ b/crypto/encode_decode/decoder_lib.c
@@ -87,9 +87,10 @@ int OSSL_DECODER_from_bio(OSSL_DECODER_CTX *ctx, BIO *in)
const char *input_structure
= ctx->input_structure != NULL ? ctx->input_structure : "";
- if (BIO_eof(in) == 0 /* Prevent spurious decoding error */)
+ if (BIO_eof(in) == 0 || ERR_peek_error() == 0)
+ /* Prevent spurious decoding error */
ERR_raise_data(ERR_LIB_OSSL_DECODER, ERR_R_UNSUPPORTED,
- "Not supported for the data to decode.%s%s%s%s%s%s",
+ "No supported data to decode. %s%s%s%s%s%s",
spaces, input_type_label, input_type, comma,
input_structure_label, input_structure);
ok = 0;