Repository navigation
[ISSUE #11500] Prevent copying a file onto itself - #11501
Open
Drifter-yh wants to merge 1 commit into
Open
Drifter-yh wants to merge 1 commit into
Drifter-yh wants to merge 1 commit into
Conversation
Drifter-yh
force-pushed
the
fix-iotinyutils-same-file
branch
from
October 29, 2026 15:50
ae14558 to
7105dff
Compare
Drifter-yh
marked this pull request as ready for review
October 29, 2026 15:59
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Which Issue(s) This PR Fixes
Fixes #11500
Brief Description
Opening the target truncates it before the source is opened. If the two paths refer to the same existing file, including a hard link, this silently destroys the source. Reject that case with an IOException before opening the destination. Normal copies retain their existing behavior.
This public utility has no production call sites in this repository; no broker-level data-loss scenario is claimed. This does not address the separate relative-target issue #11461.
How Did You Test This Change?
592d59d12db356f8c98332d9e355a89d92590db3, the same-path regression failed before the fix: expected 14 bytes, got zero.mvn -B -ntp -pl common -am -Dtest=IOTinyUtilsTest,IOTinyUtilsSameFileTest -Dsurefire.failIfNoSpecifiedTests=false -DfailIfNoTests=false teston Windows 11, Microsoft OpenJDK 17.0.14 and Maven 3.9.2: 11 tests passed, 0 failures/errors/skips; Checkstyle and SpotBugs passed. The three new cases cover the same path, a hard link, and a distinct target. The hard-link case skips if the filesystem cannot create one.git diff --checkpassed. No broker integration test or full-project test is claimed.AI assistance: OpenAI Codex was used for analysis, implementation, and tests; the changes were reviewed and tested as described above.
CI: GitHub Actions runs for head
7105dffcreportaction_required; no jobs or passing checks are reported yet. The reason is not confirmed.