Skip to content

Commit 4a999da

Browse files
yshuitru
authored andcommitted
[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 9a4b3fd)
1 parent 1b11137 commit 4a999da

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lldb/source/Host/windows/FileSystem.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ int FileSystem::Open(const char *path, int flags, int mode) {
101101
std::wstring wpath;
102102
if (!llvm::ConvertUTF8toWide(path, wpath))
103103
return -1;
104+
// All other bits are rejected by _wsopen_s
105+
mode = mode & (_S_IREAD | _S_IWRITE);
104106
int result;
105107
::_wsopen_s(&result, wpath.c_str(), flags, _SH_DENYNO, mode);
106108
return result;

0 commit comments

Comments
 (0)