aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2024-06-22 17:19:28 +0100
committerRon Yorston <rmy@pobox.com>2024-06-22 17:19:28 +0100
commit89ecbdcaab6ad1510a9f2058c4585ab4c17be743 (patch)
tree7affdaa66ca6fb481c0607abc958c71112cfd21c
parent98a0e0e272018a1ae2cc5cd4fa9775c5cfb33dec (diff)
downloadbusybox-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)
-rw-r--r--win32/mingw.c8
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);