Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

venv: do not prepend a truncated shebang interpreter #2203

Merged
merged 2 commits into from Sep 16, 2021
Merged

venv: do not prepend a truncated shebang interpreter #2203

merged 2 commits into from Sep 16, 2021

Conversation

jdknight
Copy link
Contributor

@jdknight jdknight commented Sep 5, 2021

When a user invokes a tox call with TOX_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

Copy link
Member

@gaborbernat gaborbernat left a comment

Please add a changelog for this.

jdknight added 2 commits Sep 10, 2021
When a user invokes a `tox` call with `TOX_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

Signed-off-by: James Knight <james.d.knight@live.com>
Signed-off-by: James Knight <james.d.knight@live.com>
@gaborbernat gaborbernat merged commit 51cc218 into tox-dev:master Sep 16, 2021
31 checks passed
@gaborbernat
Copy link
Member

gaborbernat commented Sep 16, 2021

@jdknight jdknight deleted the do-not-invoke-truncated-interpreter branch Sep 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants