Skip to content

Commit

Permalink
apps/x509.c: No warning reading from stdin if redirected
Browse files Browse the repository at this point in the history
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 #23526)
  • Loading branch information
t8m committed Mar 15, 2024
1 parent 37cd49f commit 5c846d3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions apps/x509.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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");
Expand Down
1 change: 1 addition & 0 deletions include/internal/e_os.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ FILE *__iob_func(void);
# endif
# define unlink _unlink
# define fileno _fileno
# define isatty _isatty
# endif
# else
# include <strings.h>
Expand Down

0 comments on commit 5c846d3

Please sign in to comment.