<filesystem>: Fix filesystem::copy() for junctions on x86
#6064
+4
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is the correct fix for the bug identified by #5976. Thanks @SiliconA-Z for finding this, @Morddin for identifying the correct constant to use (which I double-checked), and Fulgen on the STL Discord for providing the PowerShell incantation to create a junction.
Commits
_Read_reparse_data()allocates.FSCTL_GET_REPARSE_POINTcontrol code in the Windows Drivers documentation says:sizeof(wchar_t)appears to be totally unjustified and unnecessary.__std_fs_write_reparse_data_buffer().FSCTL_SET_REPARSE_POINTcontrol code in the Windows Drivers documentation says:filesystem.cpp:__std_fs_write_reparse_data_buffer()should use the size of the buffer, not buffer pointer #5976 (comment)). However, it can easily be computed and visually verified against our structure definition. The correct constant is always 8 regardless of architecture (I checked x64 and x86).sizeof(_Buffer)was measuring the size of the pointerconst __std_fs_reparse_data_buffer* const _Buffer, this bug was cloaked on x64 and ARM64 with their 8-byte pointers. This bug reproed only for x86 with its 4-byte pointers.filesystem.cpp.<xfilesystem_abi.h>where it was visible to users.Repro
Notes
I've manually verified that the fix makes both x64 and x86 succeed.
Because junctions are weird and we aren't frequently changing this code, I'm not updating our automated test coverage for this.