Skip to content

Fix box_argc mismatch in sandbox stack initialization#17

Merged
zyedidia merged 2 commits into
lfi-project:masterfrom
squk:fix/nargv
Jul 1, 2026
Merged

Fix box_argc mismatch in sandbox stack initialization#17
zyedidia merged 2 commits into
lfi-project:masterfrom
squk:fix/nargv

Conversation

@squk

@squk squk commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Use nargv (number of non-NULL arguments) instead of argc (which can
count past the first NULL arg) to prevent stack corruption during
argv/envp parsing.

squk added 2 commits June 24, 2026 21:53
Use `nargv` (number of non-NULL arguments) instead of `argc` (which can
count past the first NULL arg) to prevent stack corruption during
argv/envp parsing.

TAG=agy
CONV=0190fdf7-8c75-45c1-9535-399f772ca10f
Add a test runner `test_argv_mismatch` and register it in `meson.build` to
verify that `lfi_thread_new` correctly handles cases where `argc` is larger
than the actual number of arguments (contains trailing NULLs).
@zyedidia

Copy link
Copy Markdown
Member

I wonder if there is any case where the user may want argc to be manually set to a value other than nargv? I can't think of any such case at the moment, but I'll give it a little more thought and then merge otherwise.

@squk

squk commented Jun 26, 2026

Copy link
Copy Markdown
Contributor Author

Thanks!

@zyedidia zyedidia merged commit 40ecbf9 into lfi-project:master Jul 1, 2026
3 checks passed
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.

2 participants