Skip to content

Commit

Permalink
change check on stdin/stdout being open before using it
Browse files Browse the repository at this point in the history
  • Loading branch information
mcr authored and fxlb committed Nov 14, 2021
1 parent 34c8ff0 commit 4f4524c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pcap-ioplugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ stdio_open_read(const char *fname, char *errbuf)
if (fname[0] == '-' && fname[1] == '\0')
{
fp = stdin;
if (stdin == NULL) {
if (!stdin || ferror(stdin)) {
snprintf(errbuf, PCAP_ERRBUF_SIZE,
"The standard input is not open");
return (NULL);
Expand Down Expand Up @@ -110,7 +110,7 @@ stdio_open_write(const char *fname, char *errbuf)

if (strcmp(fname, "-") == 0) {
fp = stdout;
if (stdout == NULL) {
if (!stdout || ferror(stdout)) {
snprintf(errbuf, PCAP_ERRBUF_SIZE,
"The standard input is not open");
return (NULL);
Expand Down

0 comments on commit 4f4524c

Please sign in to comment.