Skip to content

Conversation

@ejohnstown
Copy link
Contributor

@ejohnstown ejohnstown commented Feb 2, 2026

  1. Forwarding fixes in echoserver. (Really a general channel issue.)
  2. Agent fixes in echoserver.

1. When wolfSSH_worker() receives channel data, it should set the
   channelId for the data. It was not happening. Change the check for
   WS_SUCCESS to also check for WS_CHAN_RXD.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes handling around “channel RX’d” (WS_CHAN_RXD) and agent setup paths, primarily to improve forwarding behavior in the echoserver and make agent-related code compile cleanly.

Changes:

  • Treat WS_CHAN_RXD as a successful outcome for returning lastRxId from wolfSSH_worker().
  • Silence unused-parameter warnings in agent stubs.
  • Fix echoserver agent UNIX-socket setup flow so it proceeds correctly after snprintf() and simplifies the socket() error assignment.

Reviewed changes

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

File Description
src/ssh.c Returns channelId not only on WS_SUCCESS but also on WS_CHAN_RXD so callers can identify the channel that received data.
src/agent.c Adds WOLFSSH_UNUSED(agent) to avoid unused-parameter warnings when logging is compiled out.
examples/echoserver/echoserver.c Corrects agent local setup flow after snprintf() and adjusts UNIX-socket bind/setup logic.

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

Comment on lines 399 to +402
if (ret == 0) {
ret = bind(ctx->listenFd,
(struct sockaddr *)name, (socklen_t)size);
ret = bind(ctx->listenFd, (struct sockaddr *)name,
(socklen_t)sizeof(struct sockaddr_un));
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

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

If socket() succeeds but bind()/setenv()/listen() fails, the code returns an error without closing ctx->listenFd or removing any partially-created UNIX socket path/env var. Since the agent callback return value is not always checked by the library, this can leak FDs and leave stale /tmp/wolfserver. sockets on failure. Consider adding an error-cleanup path that closes ctx->listenFd (and unlinks/unsets as applicable) before returning.

Copilot uses AI. Check for mistakes.
1. Fix a couple unused variable warnings.
2. In wolfSSH_AGENT_DefaultActions(), fix comparison to the result of
   snprintf() treating normal result as an error. Reset the return code
   for the error state of the socket() command. Remove the size variable
   and just use sizeof() the sockaddr_un. Better cleanup of agent
   startup failures.
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.

1 participant