summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2005-04-11 20:09:42 +0000
committerPaul Eggert <eggert@cs.ucla.edu>2005-04-11 20:09:42 +0000
commit02b75108661d6f9cdc953ec8a4641d761cb26c18 (patch)
tree28294551e589367ead20fe3cefbec4b7d9b02f7a
parentc2377708ecb536e6bc30997a3b9b01b48d38ea5e (diff)
downloadcoreutils-02b75108661d6f9cdc953ec8a4641d761cb26c18.tar.xz
Include stdio-safer.h.
(open_file): Use fopen_safer. (close_file): Don't assume fopen does not return stdin.
-rw-r--r--src/pr.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/pr.c b/src/pr.c
index aa3c40fcd..869e4b874 100644
--- a/src/pr.c
+++ b/src/pr.c
@@ -320,6 +320,7 @@
#include "inttostr.h"
#include "mbswidth.h"
#include "posixver.h"
+#include "stdio-safer.h"
#include "strftime.h"
#include "xstrtol.h"
@@ -1513,7 +1514,7 @@ open_file (char *name, COLUMN *p)
else
{
p->name = name;
- p->fp = fopen (name, "r");
+ p->fp = fopen_safer (name, "r");
}
if (p->fp == NULL)
{
@@ -1543,7 +1544,7 @@ close_file (COLUMN *p)
return;
if (ferror (p->fp))
error (EXIT_FAILURE, errno, "%s", p->name);
- if (p->fp != stdin && fclose (p->fp) == EOF)
+ if (fileno (p->fp) != STDIN_FILENO && fclose (p->fp) != 0)
error (EXIT_FAILURE, errno, "%s", p->name);
if (!parallel_files)