yshui created this revision.
Herald added a project: All.
yshui requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156817

Files:
  lldb/source/Host/windows/FileSystem.cpp


Index: lldb/source/Host/windows/FileSystem.cpp
===================================================================
--- lldb/source/Host/windows/FileSystem.cpp
+++ lldb/source/Host/windows/FileSystem.cpp
@@ -101,6 +101,7 @@
   std::wstring wpath;
   if (!llvm::ConvertUTF8toWide(path, wpath))
     return -1;
+  mode = mode & (_S_IREAD | _S_IWRITE); // All other bits are rejected by 
_wsopen_s
   int result;
   ::_wsopen_s(&result, wpath.c_str(), flags, _SH_DENYNO, mode);
   return result;


Index: lldb/source/Host/windows/FileSystem.cpp
===================================================================
--- lldb/source/Host/windows/FileSystem.cpp
+++ lldb/source/Host/windows/FileSystem.cpp
@@ -101,6 +101,7 @@
   std::wstring wpath;
   if (!llvm::ConvertUTF8toWide(path, wpath))
     return -1;
+  mode = mode & (_S_IREAD | _S_IWRITE); // All other bits are rejected by _wsopen_s
   int result;
   ::_wsopen_s(&result, wpath.c_str(), flags, _SH_DENYNO, mode);
   return result;
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to