[all-commits] [llvm/llvm-project] f68435: [Support][Windows] Fix incorrect GetFinalPathNameB...

Ronald Wampler via All-commits all-commits at lists.llvm.org
Tue Dec 15 15:24:18 PST 2020


  Branch: refs/heads/release/11.x
  Home:   https://github.com/llvm/llvm-project
  Commit: f684355e0292b8e24a0870ecfda126fb15c9eb93
      https://github.com/llvm/llvm-project/commit/f684355e0292b8e24a0870ecfda126fb15c9eb93
  Author: Aleksandr Platonov <platonov.aleksandr at huawei.com>
  Date:   2020-12-15 (Tue, 15 Dec 2020)

  Changed paths:
    M llvm/lib/Support/Windows/Path.inc

  Log Message:
  -----------
  [Support][Windows] Fix incorrect GetFinalPathNameByHandleW() return value check in realPathFromHandle()

`GetFinalPathNameByHandleW(,,N,)` returns:
- `< N` on success (this value does not include the size of the terminating null character)
- `>= N` if buffer is too small (this value includes the size of the terminating null character)

So, when `N == Buffer.capacity() - 1`, we need to resize buffer if return value is > `Buffer.capacity() - 2`.
Also, we can set `N` to `Buffer.capacity()`.

Thus, without this patch `realPathFromHandle()` returns unfilled buffer when length of the final path of the file is equal to `Buffer.capacity()` or `Buffer.capacity() - 1`.

Reviewed By: andrewng, amccarth

Differential Revision: https://reviews.llvm.org/D86564

(cherry picked from commit ceffd6993c350b57f43cec3b6371b159fc4a3149)


  Commit: 6ec777c2f6496b4fe1d78cc6d6871a3dc931a185
      https://github.com/llvm/llvm-project/commit/6ec777c2f6496b4fe1d78cc6d6871a3dc931a185
  Author: Ronald Wampler <rdwampler at gmail.com>
  Date:   2020-12-15 (Tue, 15 Dec 2020)

  Changed paths:
    M llvm/lib/Support/Windows/Path.inc

  Log Message:
  -----------
  [Support] PR42623: Avoid setting the delete-on-close bit if a TempFile doesn't reside on a local drive

On Windows, after commit 881ba104656c40098d4bc90c52613c08136f0fe1, tools
using TempFile would error with "bad file descriptor" when writing the
file on a network drive. It appears that setting the delete-on-close bit via
SetFileInformationByHandle/FileDispositionInfo prevented it from
accessing the file on network drives, and although using
FILE_DISPOSITION_INFO seems to work, it causes other troubles.

Differential Revision: https://reviews.llvm.org/D81803

(cherry picked from commit 79657e2339b58bc01fe1b85a448bb073d57d90bb)


Compare: https://github.com/llvm/llvm-project/compare/98f575ff55bf...6ec777c2f649


More information about the All-commits mailing list