summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2020-04-15 06:32:13 -0700
committerKaz Kylheku <kaz@kylheku.com>2020-04-15 06:32:13 -0700
commit4421b92f2f2c85fc167d3d011ad9e9188095b3cb (patch)
treee86e4747771974d4b356101440d288b1597e4079
parentcd68cb82560345ca6c97c5780837c2873c819fa6 (diff)
downloadtxr-4421b92f2f2c85fc167d3d011ad9e9188095b3cb.tar.gz
txr-4421b92f2f2c85fc167d3d011ad9e9188095b3cb.tar.bz2
txr-4421b92f2f2c85fc167d3d011ad9e9188095b3cb.zip
streams: bugfix: "m" mode: use 0666 in open.
* stream.c (w_fopen_mode): When the "m" mode is present such that we resort to a combination of POSIX open and fdopen, we must use the 0666 mode for open, not 0777. This will create a file with execute permissions, if the umask doesn't block it. It went unnoticed because umask is usually 022.
-rw-r--r--stream.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/stream.c b/stream.c
index 8856d9b8..a8177ff3 100644
--- a/stream.c
+++ b/stream.c
@@ -1089,7 +1089,7 @@ static FILE *w_fopen_mode(const wchar_t *wname, const wchar_t *mode,
if (m.notrunc) {
char *name = utf8_dup_to(wname);
int flags = (m.read ? O_RDWR : O_WRONLY) | O_CREAT;
- int fd = open(name, flags, 0777);
+ int fd = open(name, flags, 0666);
free(name);
if (fd < 0)
return NULL;