Conversation
69e1d55 to
fc39ced
Compare
There was a problem hiding this comment.
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_RXDas a successful outcome for returninglastRxIdfromwolfSSH_worker(). - Silence unused-parameter warnings in agent stubs.
- Fix echoserver agent UNIX-socket setup flow so it proceeds correctly after
snprintf()and simplifies thesocket()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.
676df52 to
773c3bf
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
JacobBarthelmeh
left a comment
There was a problem hiding this comment.
Changes look okay. I sent a message asking about expected output and return values from running the new scripts/fwd.test.
|
Assigning to John for investigating into the test case behavior. |
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.
1. Add a test script and expect script for testing forwarding. 2. Update portfwd to have a ready file option. 3. Fix echoserver error string, needed NL.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.
Comments suppressed due to low confidence (1)
examples/portfwd/portfwd.c:325
- The new
-R <readyFile>option is parsed, butShowUsage()doesn’t mention it. This makes the CLI help inaccurate; please update the usage text to document-Rand what it writes to the file.
while ((ch = mygetopt(argc, argv, "?f:h:p:t:u:F:P:R:T:")) != -1) {
switch (ch) {
case 'h':
host = myoptarg;
break;
case 'f':
if (myoptarg == NULL)
err_sys("null argument found");
fwdFromPort = (word16)atoi(myoptarg);
break;
case 'p':
if (myoptarg == NULL)
err_sys("null argument found");
port = (word16)atoi(myoptarg);
#if !defined(NO_MAIN_DRIVER) || defined(USE_WINDOWS_API)
if (port == 0)
err_sys("port number cannot be 0");
#endif
break;
case 't':
if (myoptarg == NULL)
err_sys("null argument found");
fwdToPort = (word16)atoi(myoptarg);
break;
case 'u':
username = myoptarg;
break;
case 'F':
fwdFromHost = myoptarg;
break;
case 'P':
password = myoptarg;
break;
case 'R':
readyFile = myoptarg;
break;
case 'T':
fwdToHost = myoptarg;
break;
case '?':
ShowUsage();
exit(EXIT_SUCCESS);
default:
ShowUsage();
exit(MY_EX_USAGE);
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| endif | ||
|
|
||
| dist_noinst_SCRIPTS+= scripts/external.test | ||
| dist_noinst_SCRIPTS+= scripts/external.test scripts/fwd.test |
There was a problem hiding this comment.
scripts/fwd.test depends on scripts/fwd.test.expect, but include.am only adds scripts/fwd.test to dist_noinst_SCRIPTS. This will break make distcheck / running tests from a release tarball because the .expect file won’t be distributed. Add scripts/fwd.test.expect to the dist list (or another appropriate dist_* variable) alongside scripts/fwd.test.
| dist_noinst_SCRIPTS+= scripts/external.test scripts/fwd.test | |
| dist_noinst_SCRIPTS+= scripts/external.test scripts/fwd.test scripts/fwd.test.expect |
| int l = WSNPRINTF(portStr, sizeof(portStr), "%d\n", (int)port); | ||
| WFWRITE(NULL, portStr, MIN((size_t)l, sizeof(portStr)), 1, f); |
There was a problem hiding this comment.
The ready-file writer is currently formatting/writing port (the SSH server port) rather than the local forwarded-from port that clients would need (likely fwdFromPort, which may be updated by tcp_listen() when binding ephemeral ports). Also, WSNPRINTF() can return a negative value on error; casting that to size_t can cause WFWRITE() to write an unintended length. Write the correct port value and guard against l <= 0 (and ideally handle a truncated result).
| int l = WSNPRINTF(portStr, sizeof(portStr), "%d\n", (int)port); | |
| WFWRITE(NULL, portStr, MIN((size_t)l, sizeof(portStr)), 1, f); | |
| int l = WSNPRINTF(portStr, sizeof(portStr), "%d\n", (int)fwdFromPort); | |
| if (l > 0) { | |
| size_t writeLen = (size_t)l; | |
| if (writeLen >= sizeof(portStr)) { | |
| writeLen = sizeof(portStr) - 1; | |
| } | |
| WFWRITE(NULL, portStr, writeLen, 1, f); | |
| } |
| if (envSet) { | ||
| unsetenv(EnvNameAuthPort); | ||
| } | ||
| if (ctx->listenFd >= 0) { | ||
| close(ctx->listenFd); | ||
| ctx->listenFd = -1; | ||
| } |
There was a problem hiding this comment.
If bind() succeeds but setenv() or listen() fails, the setup error path closes the FD and unsets the env var, but it does not remove the already-created UNIX socket pathname. Add an unlink(ctx->name.sun_path) (or unlink(name->sun_path)) in the failure cleanup to avoid leaving stale /tmp/wolfserver.<pid> sockets behind.
| 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)); | ||
| } |
There was a problem hiding this comment.
The bind() length was changed to sizeof(struct sockaddr_un), but elsewhere (e.g. the client-side agent code) the code computes strlen(path) + offsetof(sockaddr_un, sun_path). Using the full struct size can be less portable across UNIX variants; consider restoring the computed length here for consistency and compatibility.
| #ifdef WOLFSSH_TEST_BLOCK | ||
| if (!nonBlock) { | ||
| ES_ERROR("Use -N when testing forced non blocking"); | ||
| ES_ERROR("Use -N when testing forced non blocking\n"); |
There was a problem hiding this comment.
Hyphenation in this user-facing message is inconsistent with the common term “non-blocking”. Update the wording to “forced non-blocking”.
| ES_ERROR("Use -N when testing forced non blocking\n"); | |
| ES_ERROR("Use -N when testing forced non-blocking\n"); |
Uh oh!
There was an error while loading. Please reload this page.