Repository navigation
Conversation
"On the out-of-bounds early-return path, the function returns without
resetting `session->userauth_pswd_state` back to `ssh2_NB_state_idle`.
If the caller retries after this error, the state machine can continue
in `sent1` with `userauth_pswd_data_len == 0`, leading to a misleading
follow-up `LIBSSH2_ERROR_PROTO` ("Unexpected packet size"). Reset the
state before returning on this failure path."
Reported by Copilot.
Bug: libssh2#2224 (comment)
There was a problem hiding this comment.
Pull request overview
This PR fixes a non-blocking state-machine bug in userauth_password() by ensuring session->userauth_pswd_state is reset to ssh2_NB_state_idle on early failure paths, preventing retries from continuing in an inconsistent intermediate state and producing misleading follow-up protocol errors.
Changes:
- Reset
session->userauth_pswd_statetossh2_NB_state_idlewhen username/password bounds checks fail during the password-change flow. - Reset
session->userauth_pswd_statetossh2_NB_state_idlewhen allocation fails during the password-change flow.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Also: reset buffer length if password change callback returned NULL.
"On the out-of-bounds early-return path, the function returns without
resetting
session->userauth_pswd_stateback tossh2_NB_state_idle.If the caller retries after this error, the state machine can continue
in
sent1withuserauth_pswd_data_len == 0, leading to a misleadingfollow-up
LIBSSH2_ERROR_PROTO("Unexpected packet size"). Reset thestate before returning on this failure path."
Reported by Copilot
Bug: #2224 (comment)