4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-02-13 04:29:09 +08:00

Cygwin: try_to_bin: transpose deleted file name to valid Unicode chars

Since commit 314c2d2fedc5f ("* syscalls.cc (try_to_bin): Handle remote
shares as well.") try_to_bin() transposes the .cyg prefix for temporary
files to invalid low surrogate halfs on filesystems setting the
FILE_UNICODE_ON_DISK flag.

This works on NTFS, but not necessarily on other filesystems, which often
require all chars in a filename to be valid Unicode chars.  Fix this by
transposing into the private use area instead.

Fixes: 314c2d2fedc5f ("* syscalls.cc (try_to_bin): Handle remote shares as well.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen 2024-12-04 22:54:18 +01:00
parent 61c2f075cd
commit 0924d5f107
2 changed files with 8 additions and 5 deletions

View File

@ -51,3 +51,6 @@ Fixes:
- Fix frequent page fault caused in Windows Terminal.
Addresses: https://cygwin.com/pipermail/cygwin/2024-December/256841.html
- Fix using invalid chars in temporary file names for deleted files.
Addresses: https://cygwin.com/pipermail/cygwin/2024-November/256813.html

View File

@ -340,14 +340,14 @@ try_to_bin (path_conv &pc, HANDLE &fh, ACCESS_MASK access, ULONG flags)
else
{
/* Create unique filename. Start with a dot, followed by "cyg"
transposed into the Unicode low surrogate area (U+dc00) on file
systems supporting Unicode (except Samba), followed by the inode
number in hex, followed by a path hash in hex. The combination
allows to remove multiple hardlinks to the same file. */
transposed to the Unicode private use area in the U+f700 area
on file systems supporting Unicode (except Samba), followed by
the inode number in hex, followed by a path hash in hex. The
combination allows to remove multiple hardlinks to the same file. */
RtlAppendUnicodeToString (&recycler,
(pc.fs_flags () & FILE_UNICODE_ON_DISK
&& !pc.fs_is_samba ())
? L".\xdc63\xdc79\xdc67" : L".cyg");
? L".\xf763\xf779\xf767" : L".cyg");
pfii = (PFILE_INTERNAL_INFORMATION) infobuf;
status = NtQueryInformationFile (fh, &io, pfii, sizeof *pfii,
FileInternalInformation);