Fix SSH shell arguments and environment handling#105
Open
binaryfire wants to merge 1 commit into
Open
Conversation
Validate the actual width-without-height argument count in ssh2_shell and report the invalid call as a recoverable warning. Complete width and height pairs now reach the normal shell path. Traverse shell and exec environment arrays with paired Zend hash iterators. This makes empty shell environments safe and prevents exec keys from being combined with values from a different iterator position. Keep environment values out of setenv failure warnings while retaining the variable name for diagnosis. Add PHPT coverage for dimension validation, empty and multi-value environments, and warning redaction, and include the tests in the PECL package manifest.
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.
Summary
Fix
ssh2_shell()argument validation and make shell and exec environment handling safe and consistent.false.Details
The existing arity check tests five arguments, which rejects a valid width/height call and leaves the incomplete four-argument form unchecked. It also raises
E_ERROR, making the documentedfalsereturn unreachable.The shell environment loop uses the array's internal pointer, while the exec loop advances an external position for keys but reads values from the internal pointer. Empty shell arrays can reach invalid iterator state, and exec can pair later keys with the wrong value.
Both paths now use
ZEND_HASH_FOREACH_STR_KEY_VAL. Numeric keys retain the existing notice behavior. Failed environment requests still identify the variable, but no longer include its value.Tests
Added PHPT coverage for:
The extension builds cleanly, the package manifest validates, and the branch merges cleanly with the other open SSH2 fixes in #102, #103, and #104.