You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Reject copying a file onto itself before truncating the destination #552
fs_copy opens the source for reading, then opens the destination with fs_open_write, which uses CREAT|TRUNC. If both paths identify the same file, opening the destination truncates the source before io_copy reads it. The function can then report a successful zero-byte copy while the original contents have been destroyed. Identical path strings are the simplest case; aliases and hard links can identify the same object too.
Detect same-file identity before any destructive destination operation, including identical paths and supported aliases/hard links.
Preserve the original bytes and return an explicit error for self-copy.
Use native file identity rather than comparing only strings, lengths or timestamps; keep the check tied to the actual opened objects as far as the APIs allow.
Add guarded temporary-file cases for self-copy, aliases and ordinary copying, and cover handle cleanup on errors.
#527 concerns Windows open-flag translation. This is a separate cross-platform data-loss path in the high-level copy operation.
Audit status: static source inspection against canonical master ea74c2dafc31da876e5561f2d176ba719f5a0458 on 2026-09-10. No compiler build, test execution, implementation change or local reproduction was performed for this report. The examples describe the source-derived behavior to verify when implementing the fix.
Activity
fix: preserve numeric results, file data, and I/O deadlines (wavefnd#631