From: Tomas Mraz Date: Thu, 8 Feb 2024 16:19:19 +0000 (+0100) Subject: apps/x509.c: No warning reading from stdin if redirected X-Git-Tag: openssl-3.3.0-alpha1~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5c846d32d4a1dc7ee7934bc867b9941809b76beb;p=thirdparty%2Fopenssl.git apps/x509.c: No warning reading from stdin if redirected Fixes #22893 Reviewed-by: Tom Cosgrove Reviewed-by: Dmitry Belyavskiy Reviewed-by: Neil Horman (Merged from https://github.com/openssl/openssl/pull/23526) --- diff --git a/apps/x509.c b/apps/x509.c index ce3fda67166..f77f47709a2 100644 --- a/apps/x509.c +++ b/apps/x509.c @@ -25,6 +25,7 @@ #ifndef OPENSSL_NO_DSA # include #endif +#include "internal/e_os.h" /* For isatty() */ #undef POSTFIX #define POSTFIX ".srl" @@ -709,7 +710,7 @@ int x509_main(int argc, char **argv) } if (reqfile) { - if (infile == NULL) + if (infile == NULL && isatty(fileno_stdin())) BIO_printf(bio_err, "Warning: Reading cert request from stdin since no -in option is given\n"); req = load_csr_autofmt(infile, informat, vfyopts, @@ -762,7 +763,7 @@ int x509_main(int argc, char **argv) } } } else { - if (infile == NULL) + if (infile == NULL && isatty(fileno_stdin())) BIO_printf(bio_err, "Warning: Reading certificate from stdin since no -in or -new option is given\n"); x = load_cert_pass(infile, informat, 1, passin, "certificate"); diff --git a/include/internal/e_os.h b/include/internal/e_os.h index d1ed62e8902..24e7a9553e2 100644 --- a/include/internal/e_os.h +++ b/include/internal/e_os.h @@ -258,6 +258,7 @@ FILE *__iob_func(void); # endif # define unlink _unlink # define fileno _fileno +# define isatty _isatty # endif # else # include