From: Dr. David von Oheimb Date: Mon, 26 Apr 2021 12:51:34 +0000 (+0200) Subject: OSSL_DECODER_from_bio() Prevent spurious decoding error at EOF X-Git-Tag: openssl-3.0.0-alpha16~37 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d9efb24de8765ddc921b8e304372e8e33d4d65f4;p=thirdparty%2Fopenssl.git OSSL_DECODER_from_bio() Prevent spurious decoding error at EOF Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/15029) --- diff --git a/crypto/encode_decode/decoder_lib.c b/crypto/encode_decode/decoder_lib.c index 45aeb39184d..8a5082c441d 100644 --- a/crypto/encode_decode/decoder_lib.c +++ b/crypto/encode_decode/decoder_lib.c @@ -79,10 +79,11 @@ int OSSL_DECODER_from_bio(OSSL_DECODER_CTX *ctx, BIO *in) const char *input_structure = ctx->input_structure != NULL ? ctx->input_structure : ""; - ERR_raise_data(ERR_LIB_OSSL_DECODER, ERR_R_UNSUPPORTED, - "No supported for the data to decode.%s%s%s%s%s%s", - spaces, input_type_label, input_type, comma, - input_structure_label, input_structure); + if (BIO_eof(in) == 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", + spaces, input_type_label, input_type, comma, + input_structure_label, input_structure); ok = 0; }