summaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorShane Lontis <shane.lontis@oracle.com>2021-03-09 17:27:55 +1000
committerShane Lontis <shane.lontis@oracle.com>2021-03-11 07:57:36 +1000
commit7a45d51ce3268d16409405b9d54d7b4bb77a7fc3 (patch)
tree3ed6e0451af6ed350eec65183113788b0797d7cd /crypto
parenta30823c80f8c1f4ac22fb358cab65ce4e81a5046 (diff)
Use BIO_f_readbuffer() in the decoder to support stdin.
Fixes #13185 Fixes #13352 Removed the existing code in file_store that was trying to figure out the input type. Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14407)
Diffstat (limited to 'crypto')
-rw-r--r--crypto/encode_decode/decoder_lib.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/crypto/encode_decode/decoder_lib.c b/crypto/encode_decode/decoder_lib.c
index 635a656216..f161c7cd5b 100644
--- a/crypto/encode_decode/decoder_lib.c
+++ b/crypto/encode_decode/decoder_lib.c
@@ -39,7 +39,14 @@ int OSSL_DECODER_from_bio(OSSL_DECODER_CTX *ctx, BIO *in)
{
struct decoder_process_data_st data;
int ok = 0;
+ BIO *new_bio = NULL;
+ if (BIO_tell(in) < 0) {
+ new_bio = BIO_new(BIO_f_readbuffer());
+ if (new_bio == NULL)
+ return 0;
+ in = BIO_push(new_bio, in);
+ }
memset(&data, 0, sizeof(data));
data.ctx = ctx;
data.bio = in;
@@ -52,6 +59,10 @@ int OSSL_DECODER_from_bio(OSSL_DECODER_CTX *ctx, BIO *in)
/* Clear any internally cached passphrase */
(void)ossl_pw_clear_passphrase_cache(&ctx->pwdata);
+ if (new_bio != NULL) {
+ BIO_pop(new_bio);
+ BIO_free(new_bio);
+ }
return ok;
}