summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomas Mraz <tomas@openssl.org>2024-02-08 17:19:19 +0100
committerTomas Mraz <tomas@openssl.org>2024-03-15 09:08:19 +0100
commit52bdbb8dacfd1d2cf8b90a452c0b3c92b63a2ad5 (patch)
tree5c678ca2226c38d2b5e0bf339df6510f301df2a2
parentd078ea6fe71f341196fe998d264ebe884f1d58c0 (diff)
apps/x509.c: No warning reading from stdin if redirected
Fixes #22893 Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com> Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com> Reviewed-by: Neil Horman <nhorman@openssl.org> (Merged from https://github.com/openssl/openssl/pull/23526) (cherry picked from commit 5c846d32d4a1dc7ee7934bc867b9941809b76beb)
-rw-r--r--apps/x509.c5
-rw-r--r--include/internal/e_os.h1
2 files changed, 4 insertions, 2 deletions
diff --git a/apps/x509.c b/apps/x509.c
index 578af2364f..31b34c1f55 100644
--- a/apps/x509.c
+++ b/apps/x509.c
@@ -25,6 +25,7 @@
#ifndef OPENSSL_NO_DSA
# include <openssl/dsa.h>
#endif
+#include "internal/e_os.h" /* For isatty() */
#undef POSTFIX
#define POSTFIX ".srl"
@@ -701,7 +702,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,
@@ -754,7 +755,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 d1ed62e890..24e7a9553e 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 <strings.h>