From: Richard Levitte Date: Thu, 31 Mar 2016 06:29:39 +0000 (+0200) Subject: Make the '-in' option in apps/passwd.c less mandatory X-Git-Tag: OpenSSL_1_1_0-pre5~183 X-Git-Url: https://git.openssl.org/?p=openssl.git;a=commitdiff_plain;h=4de9913b8c2a11f17258a2ad5e357046fd221360;hp=b3895f42a9a90a74097c75e39d87ed3212be18dd Make the '-in' option in apps/passwd.c less mandatory Reviewed-by: Matt Caswell --- diff --git a/apps/passwd.c b/apps/passwd.c index f0ab243580..7ae9e88880 100644 --- a/apps/passwd.c +++ b/apps/passwd.c @@ -201,14 +201,20 @@ int passwd_main(int argc, char **argv) goto opthelp; # endif - if (infile && in_stdin) { + if (infile != NULL && in_stdin) { BIO_printf(bio_err, "%s: Can't combine -in and -stdin\n", prog); goto end; } - in = bio_open_default(infile, 'r', FORMAT_TEXT); - if (in == NULL) - goto end; + if (infile != NULL || in_stdin) { + /* + * If in_stdin is true, we know that infile is NULL, and that + * bio_open_default() will give us back an alias for stdin. + */ + in = bio_open_default(infile, 'r', FORMAT_TEXT); + if (in == NULL) + goto end; + } if (usecrypt) pw_maxlen = 8;