OSSL_DECODER_from_bio() Prevent spurious decoding error at EOF
authorDr. David von Oheimb <David.von.Oheimb@siemens.com>
Mon, 26 Apr 2021 12:51:34 +0000 (14:51 +0200)
committerDr. David von Oheimb <dev@ddvo.net>
Tue, 4 May 2021 16:16:48 +0000 (18:16 +0200)
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15029)

crypto/encode_decode/decoder_lib.c

index 45aeb39184d1f74b751fdaea35bfb482c09366bf..8a5082c441d86ce83d689e384620b03dc3290123 100644 (file)
@@ -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;
     }