Skip to content

Close the small gaps a review of the library found - #127

Merged
linroid merged 1 commit into
mainfrom
fix/review-low-library
Oct 28, 2026
Merged

linroid merged 1 commit into
mainfrom
fix/review-low-library

Conversation

@linroid

@linroid linroid commented Oct 28, 2026

Copy link
Copy Markdown
Owner

Eight low-severity findings from a robustness review, none of which changes a patch's bytes.

  • Output through a dangling symlink (KiffFiles.replace): on JVM, okio reports the link as existing and canonicalize then throws a bare FileNotFoundException. The link is now replaced like a missing file, as the comment said. New test aLinkToNothingIsReplacedLikeAMissingFile.
  • Repeated source ranges on apply (PatchPayload.Restore.read): a TEXT or COLUMNS region naming the same range as the previous one reuses that read instead of reading the source again. A crafted patch could name the whole source from thousands of regions; the bound for different ranges is the one FORMAT.md states and is unchanged.
  • Scanner lifetimes (ContainerEncoder): the whole-source scanner is closed after the encode, and a group's scanners are closed in finally. Matters only for a caller's DeltaAlgorithm that holds resources.
  • Dead line in Pairing.byContent: the un-pair branch could never run; the map now plainly keeps the first child per key, which is what it did.
  • Permission bits (posixMain/FileAttributes.kt): native copied the setuid, setgid and sticky bits onto a replaced file while JVM copied only the nine permission bits. Both now copy nine.
  • Array-size band (Materialize.requireIndexable): a source of exactly Int.MAX_VALUE bytes passed the check and died with OutOfMemoryError; the shared LARGEST_ARRAY limit is used.
  • Directory as source (fileSource): refused on open with UnsupportedInput rather than failing on the first read on Linux/macOS. New JVM test.
  • Octal escape in quoted diff names (UnifiedDiff.nameOf): \777 wrapped silently to a byte; it is refused as git does.

Validation: ./gradlew jvmTest :library:checkKotlinAbi :library:macosArm64Test pass. The ABI dump is unchanged.

- A symlink to nothing at the output path made the JVM fail with a
  bare "no such file": the link exists, so it was canonicalized, which
  has nothing to resolve to. It is now replaced like a missing file,
  as the comment beside it always said.
- A text or column region that names the range the last one named is
  served from that read rather than reading the source again, which
  was the cheapest way for a patch to make a reader work.
- The encoder closes the whole-source scanner it built, and a group's
  scanners even when a child fails, for an algorithm that holds
  something in one; the bundled one holds nothing.
- Pairing by content kept the first child with a key but also carried
  a line that could never run; it now says what it does.
- A native replace carried setuid, setgid and sticky bits onto the
  new file where the JVM carried the nine permission bits. Both now
  carry nine: a kernel clears the first two on the write anyway, and
  a new file should not inherit a privilege from the one it replaces.
- A source of exactly Int.MAX_VALUE bytes was accepted and then failed
  to allocate; the limit is the largest array a JVM holds, as the
  whole-file read already used.
- A directory given as a source opened on Linux and macOS and failed
  on its first read, partway through; it is refused when opened.
- A quoted name's octal escape past \377 wrapped to a byte; it is
  refused, as git refuses it.
@claude

claude Bot commented Oct 28, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@github-actions

Copy link
Copy Markdown

Test Results

2 115 tests  +7   2 115 ✅ +7   2m 5s ⏱️ +3s
  211 suites ±0       0 💤 ±0 
  211 files   ±0       0 ❌ ±0 

Results for commit b3a6087. ± Comparison against base commit 28c4439.

@linroid
linroid merged commit d9a3e18 into main Oct 28, 2026
26 checks passed
@linroid
linroid deleted the fix/review-low-library branch October 28, 2026 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant