mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2026-11-19 03:33:43 +03:00
Include stdio-safer.h.
(open_file): Use fopen_safer. (close_file): Don't assume fopen does not return stdin.
This commit is contained in:
1 parent
c2377708ec
commit
02b7510866
1 file changed
+3
-2
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user