From 4421b92f2f2c85fc167d3d011ad9e9188095b3cb Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 15 Apr 2020 06:32:13 -0700 Subject: 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. --- stream.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; -- cgit v1.2.3