Repository navigation
Conversation
The Windows branch compared names with strcmp, so an output path that named the input with a different case, a ./ prefix or an absolute path was not detected and the input was truncated when the output was opened. Compare the volume serial number and file index instead. Fixes meta#4852
|
Hi @ck0i! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
What and why
On Windows,
UTIL_isSameFile()andUTIL_isSameFileStat()compared the two paths withstrcmp. Any other spelling of the input passed to-o(different case, a./or.\prefix, an absolute path,dir\..\file, a hard link) got past the check, andFIO_openDstFile()then truncated the input when opening the output. With a 200 byte input,zstd -f a.bin -o A.binexited 0 and lefta.binas a 13 byte frame of empty content. Fixes #4852.The Windows branch now opens both paths with
FILE_READ_ATTRIBUTESand compares the volume serial number and file index fromGetFileInformationByHandle(), the same idea as thest_dev/st_inocheck on POSIX. An exact name match still returns early, and a path that cannot be opened counts as a different file. The source vs dictionary check goes throughUTIL_isSameFileStat()and picks up the same behavior.playTests.shgets a-o ./tmpcase on all platforms and a-o TMPcase on Windows. Both fail with the currentdevbuild under MSVC and pass with this change, and the fullplayTests.shpasses on Windows with an MSVC x64 build.Checklist
Tools used
This PR was filed by an automated agent.