[Lldb-commits] [PATCH] D156817: _wsopen_s does not accept bits other than `_S_IREAD | _S_IWRITE`

yshui via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Aug 1 10:48:31 PDT 2023


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;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156817.546133.patch
Type: text/x-patch
Size: 491 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230801/0dd37d36/attachment-0001.bin>


More information about the lldb-commits mailing list