unbuffer stdin before get passwd from stdin

commond LD_LIBRARY_PATH= openssl rsa -aes256 -passout stdin <<< "xxxxxx” will get pass(fun app_get_pass()) from stdin first, and then load key(fun load_key()). but it unbuffer stdin before load key, this will cause the load key to fail.

now unbuffer stdin before get pass, this will solve https://github.com/openssl/openssl/issues/19835

CLA: trivial

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19851)

(cherry picked from commit efec0f4611)
This commit is contained in:
wangyuhang 2022-12-07 16:48:16 +08:00 committed by Pauli
parent 17bd383dd2
commit 4343b2923a
1 changed files with 1 additions and 0 deletions

View File

@ -308,6 +308,7 @@ static char *app_get_pass(const char *arg, int keepbio)
pwdbio = BIO_push(btmp, pwdbio);
#endif
} else if (strcmp(arg, "stdin") == 0) {
unbuffer(stdin);
pwdbio = dup_bio_in(FORMAT_TEXT);
if (pwdbio == NULL) {
BIO_printf(bio_err, "Can't open BIO for stdin\n");