Repository navigation
server: keep argv copy NULL-terminated in calc_command_start - #1576
Open
arnaldo-delisio wants to merge 1 commit into
Open
arnaldo-delisio wants to merge 1 commit into
arnaldo-delisio wants to merge 1 commit into
Conversation
The copy had room for argc pointers and no terminator. When the command ends in an option-like word that takes a value (bash -i), musl's getopt sets optind to argc + 1 and permutes up to argv[argc], writing past the buffer, and the static binaries crash at free(argv_copy).
This branch has not been deployed
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.
Fixes #1575.
calc_command_start()copied argv intoargcslots with no NULL terminator. When the command ends in something that looks like a ttyd option taking a value (bash -i), musl'sgetopt_longsetsoptindtoargc + 1and permutes up toargv[argc], writing past the buffer. The static release binaries then crash atfree(argv_copy).The copy now has
argc + 1slots withargv_copy[argc] = NULL, like a real argv. The cleanup loop frees up to indexargc, because the permutation can move one of the strdup'd strings into that slot.Not built or run here: I have no musl toolchain available. The crash itself is reproduced with the 1.7.7 release binary, see the issue.