diff options
author | Ron Yorston <rmy@pobox.com> | 2024-06-22 17:19:28 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2024-06-22 17:19:28 +0100 |
commit | 89ecbdcaab6ad1510a9f2058c4585ab4c17be743 (patch) | |
tree | 7affdaa66ca6fb481c0607abc958c71112cfd21c /win32 | |
parent | 98a0e0e272018a1ae2cc5cd4fa9775c5cfb33dec (diff) | |
download | busybox-w32-89ecbdcaab6ad1510a9f2058c4585ab4c17be743.tar.gz busybox-w32-89ecbdcaab6ad1510a9f2058c4585ab4c17be743.tar.bz2 busybox-w32-89ecbdcaab6ad1510a9f2058c4585ab4c17be743.zip |
win32: only access mode argument of open(2) if required
The wrapper function 'mingw_open()' should only read the optional
third argument if the 'O_CREAT' flag bit is set.
Adds 16 bytes.
(GitHub issue #425)
Diffstat (limited to 'win32')
-rw-r--r-- | win32/mingw.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/win32/mingw.c b/win32/mingw.c index 49e1bcfa4..6ad514ad4 100644 --- a/win32/mingw.c +++ b/win32/mingw.c | |||
@@ -239,9 +239,11 @@ int mingw_open (const char *filename, int oflags, ...) | |||
239 | return fd; | 239 | return fd; |
240 | } | 240 | } |
241 | 241 | ||
242 | va_start(args, oflags); | 242 | if ((oflags & O_CREAT)) { |
243 | mode = va_arg(args, int); | 243 | va_start(args, oflags); |
244 | va_end(args); | 244 | mode = va_arg(args, int); |
245 | va_end(args); | ||
246 | } | ||
245 | 247 | ||
246 | pmode = ((mode & S_IWUSR) ? _S_IWRITE : 0) | | 248 | pmode = ((mode & S_IWUSR) ? _S_IWRITE : 0) | |
247 | ((mode & S_IRUSR) ? _S_IREAD : 0); | 249 | ((mode & S_IRUSR) ? _S_IREAD : 0); |