Skip to content

wolfSSH_get_fd: return socket sentinel on NULL - #1247

Merged
padelsbach merged 2 commits into
wolfSSL:masterfrom
ejohnstown:upd-man
Sep 11, 2026
Merged

padelsbach merged 2 commits into
wolfSSL:masterfrom
ejohnstown:upd-man

Conversation

@ejohnstown

Copy link
Copy Markdown
Contributor

Found while updating the wolfSSH manual. wolfSSH_get_fd() returns a WS_SOCKET_T, but on a NULL ssh the non-Windows build returned the error enum WS_BAD_ARGUMENT (-1002), which is not a socket value.

  • Return -1, the sentinel wolfSSH_new() initializes rfd/wfd to, so both builds hand back a value callers can compare as a socket.

- Return -1 on both (Windows build and not), the sentinel wolfSSH_new()
  uses for rfd/wfd.
@ejohnstown
ejohnstown requested review from wolfSSL-Fenrir-bot and a lite review from Copilot September 10, 2026 22:48

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot 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.

Fenrir Automated Review — PR #1247

Scan targets checked: wolfssh-src, wolfssh-bugs

Fenrir result: Approved ✅

No new issues found in the changed files.

Advisory only — this automated result does not count as a GitHub approval.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Add regression coverage for the invalid-socket sentinel behavior.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Updates wolfSSH_get_fd() to return the platform’s invalid socket sentinel for NULL sessions.

Changes:

  • Returns INVALID_SOCKET on Windows and -1 elsewhere.
  • Aligns behavior with socket initialization in wolfSSH_new().
  • Moderate finding: add a regression assertion for the platform invalid-socket sentinel.
File summaries
File Summary
src/ssh.c Adjusts NULL-session socket handling.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/ssh.c
test_wolfSSH_set_fd() compares the NULL return of wolfSSH_get_fd()
against the platform invalid-socket sentinel, the value wolfSSH_new()
initializes rfd/wfd to. The old check only asserted the result was not
WS_SUCCESS, which the previous WS_BAD_ARGUMENT return also satisfied.
@padelsbach
padelsbach merged commit 28bf47d into wolfSSL:master Sep 11, 2026
185 checks passed
@ejohnstown
ejohnstown deleted the upd-man branch September 11, 2026 01:58
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.

5 participants