diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2005-04-11 20:11:08 +0000 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2005-04-11 20:11:08 +0000 |
commit | a49886985520db7fe507802a15f8a9ee991be07f (patch) | |
tree | 622fdb4e2e8512e24f10eaf4fd3ea61a0ed6fbfb | |
parent | 66729cdcd355a611691e99022032bd3df91e0a37 (diff) | |
download | coreutils-a49886985520db7fe507802a15f8a9ee991be07f.tar.xz |
Include unistd-safer.h.
(cwrite): Use fd_safer. Replace mystery constant 0666 with symbolic
version, as POSIX requires.
-rw-r--r-- | src/split.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/split.c b/src/split.c index 32f90a372..e820eb83b 100644 --- a/src/split.c +++ b/src/split.c @@ -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); } |