mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2026-11-19 03:33:43 +03:00
Include unistd-safer.h.
(cwrite): Use fd_safer. Replace mystery constant 0666 with symbolic version, as POSIX requires.
This commit is contained in:
1 parent
66729cdcd3
commit
a498869855
1 file changed
+5
-2
+5
-2
@@ -37,6 +37,7 @@
|
||||
#include "posixver.h"
|
||||
#include "quote.h"
|
||||
#include "safe-read.h"
|
||||
#include "unistd-safer.h"
|
||||
#include "xstrtol.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
@@ -212,8 +213,10 @@ cwrite (bool new_file_flag, const char *bp, size_t bytes)
|
||||
next_file_name ();
|
||||
if (verbose)
|
||||
fprintf (stderr, _("creating file `%s'\n"), outfile);
|
||||
output_desc = open (outfile,
|
||||
O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666);
|
||||
output_desc = fd_safer (open (outfile,
|
||||
O_WRONLY | O_CREAT | O_TRUNC | O_BINARY,
|
||||
(S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP
|
||||
| S_IROTH | S_IWOTH)));
|
||||
if (output_desc < 0)
|
||||
error (EXIT_FAILURE, errno, "%s", outfile);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user