From 05658aba859f64074f07d73f64eb8ab1cf831334 Mon Sep 17 00:00:00 2001 From: John Safranek Date: Mon, 2 Feb 2026 11:11:32 -0800 Subject: [PATCH 1/2] RxD Fix 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. --- src/ssh.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ssh.c b/src/ssh.c index c30d5fd4a..c6d7508c0 100644 --- a/src/ssh.c +++ b/src/ssh.c @@ -2605,7 +2605,7 @@ int wolfSSH_worker(WOLFSSH* ssh, word32* channelId) } #endif /* WOLFSSH_TEST_BLOCK */ - if (ret == WS_SUCCESS) { + if (ret == WS_SUCCESS || ret == WS_CHAN_RXD) { if (channelId != NULL) { *channelId = ssh->lastRxId; } From f18c692640653bc684d650f4b08e7a2878419dda Mon Sep 17 00:00:00 2001 From: John Safranek Date: Tue, 3 Feb 2026 19:52:00 -0800 Subject: [PATCH 2/2] Agent Update 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. --- examples/echoserver/echoserver.c | 22 +++++++++++++--------- src/agent.c | 2 ++ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/examples/echoserver/echoserver.c b/examples/echoserver/echoserver.c index cbf2662b4..b0d9be88f 100644 --- a/examples/echoserver/echoserver.c +++ b/examples/echoserver/echoserver.c @@ -382,7 +382,7 @@ static int wolfSSH_AGENT_DefaultActions(WS_AgentCbAction action, void* vCtx) if (action == WOLFSSH_AGENT_LOCAL_SETUP) { struct sockaddr_un* name = &ctx->name; - size_t size; + int envSet = 0; WMEMSET(name, 0, sizeof(struct sockaddr_un)); ctx->pid = getpid(); @@ -391,19 +391,15 @@ static int wolfSSH_AGENT_DefaultActions(WS_AgentCbAction action, void* vCtx) ret = snprintf(name->sun_path, sizeof(name->sun_path), "/tmp/wolfserver.%d", ctx->pid); - if (ret == 0) { + if (ret > 0) { name->sun_path[sizeof(name->sun_path) - 1] = '\0'; - size = WSTRLEN(name->sun_path) + - offsetof(struct sockaddr_un, sun_path); ctx->listenFd = socket(AF_UNIX, SOCK_STREAM, 0); - if (ctx->listenFd == -1) { - ret = -1; - } + ret = (ctx->listenFd == -1) ? -1 : 0; } 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)); } if (ret == 0) { @@ -411,6 +407,7 @@ static int wolfSSH_AGENT_DefaultActions(WS_AgentCbAction action, void* vCtx) } if (ret == 0) { + envSet = 1; ret = listen(ctx->listenFd, 5); } @@ -418,6 +415,13 @@ static int wolfSSH_AGENT_DefaultActions(WS_AgentCbAction action, void* vCtx) ctx->state = AGENT_STATE_LISTEN; } else { + if (envSet) { + unsetenv(EnvNameAuthPort); + } + if (ctx->listenFd >= 0) { + close(ctx->listenFd); + ctx->listenFd = -1; + } ret = WS_AGENT_SETUP_E; } } diff --git a/src/agent.c b/src/agent.c index de918769c..bed5bd836 100644 --- a/src/agent.c +++ b/src/agent.c @@ -374,6 +374,7 @@ static int PostLock(WOLFSSH_AGENT_CTX* agent, word32 ppSz; WLOG(WS_LOG_AGENT, "Posting lock to agent %p", agent); + WOLFSSH_UNUSED(agent); ppSz = sizeof(pp) - 1; if (passphraseSz < ppSz) @@ -395,6 +396,7 @@ static int PostUnlock(WOLFSSH_AGENT_CTX* agent, word32 ppSz; WLOG(WS_LOG_AGENT, "Posting unlock to agent %p", agent); + WOLFSSH_UNUSED(agent); ppSz = sizeof(pp) - 1; if (passphraseSz < ppSz)