Repository navigation
fix(fspy): read the whole shebang line - #788
Merged
Merged
Conversation
lifeiscontent
added a commit
to lifeiscontent/vite-task
that referenced
this pull request
Oct 2, 2026
wan9chi
force-pushed
the
fix/fspy-long-shebang
branch
from
October 12, 2026 09:54
45f64e7 to
c6d9ea6
Compare
wan9chi
pushed a commit
to lifeiscontent/vite-task
that referenced
this pull request
Oct 12, 2026
fspy read only the first 128 bytes of a script to find its interpreter, so an interpreter path longer than 126 bytes was cut short. The traced exec then ran the truncated path, which fails or runs a different program, while the same script runs fine without tracing. Read as much as the kernel does instead: 512 bytes on macOS and 256 on Linux. Where the kernel refuses a line that doesn't fit, return ENOEXEC like it does rather than running a truncated path.
On macOS, `#` ends the shebang line like a newline does (`IS_EOL` in XNU's `exec_shell_imgact`). Reading 512 bytes instead of 128 made a `#` past the first 128 bytes part of the interpreter or its arguments, and a line without a newline in its first 512 bytes failed with ENOEXEC even when a `#` ended it. On Linux, when the 256-byte buffer fills up without a newline, the space or tab after the interpreter path can be the buffer's last byte. The kernel looks for it there before dropping that byte, but fspy dropped the byte first and refused the script. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
wan9chi
force-pushed
the
fix/fspy-long-shebang
branch
from
October 12, 2026 09:56
c6d9ea6 to
469b59b
Compare
fspy only swaps the arm64e `/bin/sh` for its own shell when it's run by that path. Through the test's symlink it injects the arm64 preload instead, and dyld refuses to load it where SIP is off, as on the CI runners. The script still runs on Linux; on macOS the test checks that the whole 200-byte interpreter path was read, which the 128-byte read didn't do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
|
Thank you! |
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.
Motivation
fspy reads only the first 128 bytes of a script to find its interpreter. A script whose interpreter path is longer than 126 bytes runs fine on its own, but under a cached task the path gets cut short. The exec then fails with ENOENT, or runs whatever lives at the shorter path.
Changes