summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@microsoft.com>2015-02-13 09:18:49 -0500
committerEdward Thomson <ethomson@microsoft.com>2015-02-13 09:18:49 -0500
commit527ed59ad809826e43fa43024b0af262f08499db (patch)
tree8a885a59df8ad325543a8912827b528af9daf0ab
parent0b2ee7c07c7b494b432ad5b2a870f6378e191f25 (diff)
downloadlibgit2-527ed59ad809826e43fa43024b0af262f08499db.tar.gz
win32: limit the mode to `_wopen`/`_waccess`
Win32 generally ignores Unix-like mode bits that don't make any sense on the platform (eg `0644` makes no sense to Windows). But WINE complains loudly when presented with POSIXy bits. Remove them. (Thanks @phkelley)
-rw-r--r--src/win32/posix_w32.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/win32/posix_w32.c b/src/win32/posix_w32.c
index 346f537e4..6e005c1cd 100644
--- a/src/win32/posix_w32.c
+++ b/src/win32/posix_w32.c
@@ -33,6 +33,12 @@
* inheritable on Windows, so specify the flag to get default behavior back. */
#define STANDARD_OPEN_FLAGS (_O_BINARY | _O_NOINHERIT)
+/* Allowable mode bits on Win32. Using mode bits that are not supported on
+ * Win32 (eg S_IRWXU) is generally ignored, but Wine warns loudly about it
+ * so we simply remove them.
+ */
+#define WIN32_MODE_MASK (_S_IREAD | _S_IWRITE)
+
/* GetFinalPathNameByHandleW signature */
typedef DWORD(WINAPI *PFGetFinalPathNameByHandleW)(HANDLE, LPWSTR, DWORD, DWORD);
@@ -343,7 +349,7 @@ int p_open(const char *path, int flags, ...)
va_end(arg_list);
}
- return _wopen(buf, flags | STANDARD_OPEN_FLAGS, mode);
+ return _wopen(buf, flags | STANDARD_OPEN_FLAGS, mode & WIN32_MODE_MASK);
}
int p_creat(const char *path, mode_t mode)
@@ -353,7 +359,9 @@ int p_creat(const char *path, mode_t mode)
if (git_win32_path_from_utf8(buf, path) < 0)
return -1;
- return _wopen(buf, _O_WRONLY | _O_CREAT | _O_TRUNC | STANDARD_OPEN_FLAGS, mode);
+ return _wopen(buf,
+ _O_WRONLY | _O_CREAT | _O_TRUNC | STANDARD_OPEN_FLAGS,
+ mode & WIN32_MODE_MASK);
}
int p_getcwd(char *buffer_out, size_t size)
@@ -607,7 +615,7 @@ int p_access(const char* path, mode_t mode)
if (git_win32_path_from_utf8(buf, path) < 0)
return -1;
- return _waccess(buf, mode);
+ return _waccess(buf, mode & WIN32_MODE_MASK);
}
static int ensure_writable(wchar_t *fpath)