[llvm-branch-commits] [lldb] 4a999da - [lldb][windows] _wsopen_s does not accept bits other than `_S_IREAD | _S_IWRITE`
Tobias Hieta via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Aug 31 23:27:28 PDT 2023
Author: Yuxuan Shui
Date: 2023-08-31T08:59:53+02:00
New Revision: 4a999da2142229f0d2a3598331ce55a1323929bd
URL: https://github.com/llvm/llvm-project/commit/4a999da2142229f0d2a3598331ce55a1323929bd
DIFF: https://github.com/llvm/llvm-project/commit/4a999da2142229f0d2a3598331ce55a1323929bd.diff
LOG: [lldb][windows] _wsopen_s does not accept bits other than `_S_IREAD | _S_IWRITE`
When sending file from a Linux host to a Windows remote, Linux host will try to copy the source file's permission bits, which will contain `_S_I?GRP` and `_S_I?OTH` bits. Those bits are rejected by `_wsopen_s`, causing it to return EINVAL.
This patch masks out the rejected bits.
GitHub issue: #64313
Reviewed By: jasonmolenda, DavidSpickett
Differential Revision: https://reviews.llvm.org/D156817
(cherry picked from commit 9a4b3fdb82327e808213070fd157be3c557b8b9d)
Added:
Modified:
lldb/source/Host/windows/FileSystem.cpp
Removed:
################################################################################
diff --git a/lldb/source/Host/windows/FileSystem.cpp b/lldb/source/Host/windows/FileSystem.cpp
index b919d9bcd9dd4a..4b0cd74b8013b0 100644
--- a/lldb/source/Host/windows/FileSystem.cpp
+++ b/lldb/source/Host/windows/FileSystem.cpp
@@ -101,6 +101,8 @@ int FileSystem::Open(const char *path, int flags, int mode) {
std::wstring wpath;
if (!llvm::ConvertUTF8toWide(path, wpath))
return -1;
+ // All other bits are rejected by _wsopen_s
+ mode = mode & (_S_IREAD | _S_IWRITE);
int result;
::_wsopen_s(&result, wpath.c_str(), flags, _SH_DENYNO, mode);
return result;
More information about the llvm-branch-commits
mailing list