venv: do not prepend a truncated shebang interpreter #2203
Merged
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.
When a user invokes a
tox
call withTOX_LIMITED_SHEBANG
set, any shebang-based scripts will have their interpreter's extracted and explicitly executed. An issue with the initial implementation is that if the configured interpreter is truncated to a path of another executable, the wrong executable can be invoked instead (see also [1][2]). To prevent this, an extra byte is read to ensure the length of the extracted interpreter is within the configured limit (MAXINTERP
); otherwise the call will know the interpreter has been truncated and will fallback onto the original argument list.[1]: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/fs/binfmt_script.c?id=8099b047ecc431518b9bb6bdbba3549bbecdc343
[2]: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/fs/binfmt_script.c?id=b5372fe5dc84235dbe04998efdede3c4daa866a9