Merge pull request #919 from yosuke-wolfssl/f_2871

Fix DoChannelOpen() and Add the regress test
pull/918/head
JacobBarthelmeh 2026-04-15 15:33:01 -06:00 committed by GitHub
commit cdd6df0c38
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 30 additions and 0 deletions

View File

@ -8739,6 +8739,12 @@ static int DoChannelOpen(WOLFSSH* ssh,
ssh->fwdCbCtx, NULL, newChannel->channel);
}
}
else {
WLOG(WS_LOG_WARN, "No forward callback set for direct-tcpip channel,"
" failing channel open");
fail_reason = OPEN_ADMINISTRATIVELY_PROHIBITED;
ret = WS_ERROR;
}
}
#endif /* WOLFSSH_FWD */
if (ret == WS_SUCCESS) {

View File

@ -1219,6 +1219,29 @@ static void TestDirectTcpipRejectSendsOpenFail(void)
FreeChannelOpenHarness(&harness);
}
static void TestDirectTcpipNoFwdCbSendsOpenFail(void)
{
ChannelOpenHarness harness;
byte extra[128];
byte in[192];
word32 extraSz;
word32 inSz;
int ret;
extraSz = BuildDirectTcpipExtra("127.0.0.1", 8080, "127.0.0.1", 2222,
extra, sizeof(extra));
inSz = BuildChannelOpenPacket("direct-tcpip", 9, 0x4000, 0x8000,
extra, extraSz, in, sizeof(in));
InitChannelOpenHarness(&harness, in, inSz);
/* Intentionally do NOT register fwdCb */
ret = DoReceive(harness.ssh);
AssertChannelOpenFailResponse(&harness, ret);
FreeChannelOpenHarness(&harness);
}
#endif
#ifdef WOLFSSH_AGENT
@ -1683,6 +1706,7 @@ int main(int argc, char** argv)
TestChannelOpenCallbackRejectSendsOpenFail();
#ifdef WOLFSSH_FWD
TestDirectTcpipRejectSendsOpenFail();
TestDirectTcpipNoFwdCbSendsOpenFail();
#endif
#ifdef WOLFSSH_AGENT
TestAgentChannelNullAgentSendsOpenFail();