Skip to content

userauth: check for NULL session, where missing - #2290

Closed
vszakats wants to merge 3 commits into
libssh2:masterfrom
vszakats:ua-null-session
Closed

vszakats wants to merge 3 commits into
libssh2:masterfrom
vszakats:ua-null-session

Conversation

@vszakats

@vszakats vszakats commented Jul 13, 2026 •

Copy link
Copy Markdown
Member

To avoid NULL dereference when called with session == NULL.

@vszakats
vszakats requested a review from Copilot July 13, 2026 23:39
@vszakats vszakats changed the title userauth: check for NULL session where missing userauth: check for NULL session, where missing Jul 13, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds defensive NULL-session validation to several user authentication entry points in src/userauth.c to avoid NULL dereferences and provide consistent failure behavior when APIs are misused.

Changes:

  • Add early if(!session) guards to multiple libssh2_userauth_* wrappers and related helpers.
  • Return NULL for pointer-returning APIs and LIBSSH2_ERROR_BAD_USE for most int-returning APIs when session is NULL.
  • Extend NULL checks to SK signing and several publickey/hostbased/password/keyboard-interactive auth entry points.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/userauth.c Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread src/userauth.c
Comment on lines 884 to +889
LIBSSH2_PRIVKEY_SK *sk_info = (LIBSSH2_PRIVKEY_SK *)(*abstract);
LIBSSH2_SK_SIG_INFO sig_info = { 0 };

if(!session)
return LIBSSH2_ERROR_BAD_USE;

@vszakats vszakats Jul 13, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not like this, but yeah.

edit: not tackling this here because it's unrelated and a problem for all APIs.

@vszakats vszakats closed this in 579cc07 Jul 14, 2026
@vszakats
vszakats deleted the ua-null-session branch July 14, 2026 00:04
vszakats added a commit that referenced this pull request Jul 14, 2026
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