Skip to content

Bun.write(file, Bun.stdin): splice a pipe source into any destination on Linux - #36692

Open
robobun wants to merge 6 commits into
mainfrom
farm/50f97965/bun-write-stdin-pipe
Open

Bun.write(file, Bun.stdin): splice a pipe source into any destination on Linux#36692
robobun wants to merge 6 commits into
mainfrom
farm/50f97965/bun-write-stdin-pipe

copy_file: use bun_sys::ftruncate instead of libc::ftruncate

dc5c7f3
Select commit
Loading
Failed to load commit list.
Claude / Claude Code Review completed Aug 2, 2026 in 27m 4s

Code review found 1 potential issue

Found 1 candidates, confirmed 1. See review comments for details.

Details

Severity Count
🔴 Important 0
🟡 Nit 1
🟣 Pre-existing 0
Severity File:Line Issue
🟡 Nit src/runtime/webcore/blob/copy_file.rs:881-886 macOS/FreeBSD post-fcopyfile ftruncate not gated on bun_opened_dest

Annotations

Check warning on line 886 in src/runtime/webcore/blob/copy_file.rs

See this annotation in the file changed.

@claude claude / Claude Code Review

macOS/FreeBSD post-fcopyfile ftruncate not gated on bun_opened_dest

The `bun_opened_dest` guard was added to all three Linux read/write-fallback `ftruncate` sites, but the macOS post-`fcopyfile` `ftruncate` (which this PR restructures) and the FreeBSD block still truncate `self.destination_fd` unconditionally — so on macOS `Bun.write(Bun.stdout, Bun.file('big.txt').slice(0, N))` with `>> log.txt` will `ftruncate(1, N)` and destroy the pre-existing bytes. Pre-existing and a narrow trigger (sliced regular-file source + user fd dest), but per REVIEW.md's "fix the w