[PATCH] D55624: Windows rename_internal function incorrectly passing character count instead of byte count to SetFileInformationByHandle.

Ben Hillis via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 12 15:14:17 PST 2018


benhillis created this revision.
benhillis added reviewers: Bigcheese, probinson.
Herald added subscribers: llvm-commits, kristina.

The rename_internal function used for Windows has a minor bug where the filename length is passed as a character count instead of a byte count.  Windows internally ignores this field, but other tools that hook NT api's may use the documented behavior:

MSDN documentation specifying the size should be in bytes:
https://docs.microsoft.com/en-us/windows/desktop/api/winbase/ns-winbase-_file_rename_info


Repository:
  rL LLVM

https://reviews.llvm.org/D55624

Files:
  lib/Support/Windows/Path.inc


Index: lib/Support/Windows/Path.inc
===================================================================
--- lib/Support/Windows/Path.inc
+++ lib/Support/Windows/Path.inc
@@ -418,3 +418,3 @@
   RenameInfo.RootDirectory = 0;
-  RenameInfo.FileNameLength = ToWide.size();
+  RenameInfo.FileNameLength = (ToWide.size() * sizeof(wchar_t));
   std::copy(ToWide.begin(), ToWide.end(), &RenameInfo.FileName[0]);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55624.177949.patch
Type: text/x-patch
Size: 404 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181212/1a6662af/attachment.bin>


More information about the llvm-commits mailing list