Skip to content

Commit cdd6df0

Browse files
Merge pull request #919 from yosuke-wolfssl/f_2871
Fix DoChannelOpen() and Add the regress test
2 parents f291d99 + 0317c40 commit cdd6df0

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

src/internal.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8739,6 +8739,12 @@ static int DoChannelOpen(WOLFSSH* ssh,
87398739
ssh->fwdCbCtx, NULL, newChannel->channel);
87408740
}
87418741
}
8742+
else {
8743+
WLOG(WS_LOG_WARN, "No forward callback set for direct-tcpip channel,"
8744+
" failing channel open");
8745+
fail_reason = OPEN_ADMINISTRATIVELY_PROHIBITED;
8746+
ret = WS_ERROR;
8747+
}
87428748
}
87438749
#endif /* WOLFSSH_FWD */
87448750
if (ret == WS_SUCCESS) {

tests/regress.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,6 +1219,29 @@ static void TestDirectTcpipRejectSendsOpenFail(void)
12191219

12201220
FreeChannelOpenHarness(&harness);
12211221
}
1222+
1223+
static void TestDirectTcpipNoFwdCbSendsOpenFail(void)
1224+
{
1225+
ChannelOpenHarness harness;
1226+
byte extra[128];
1227+
byte in[192];
1228+
word32 extraSz;
1229+
word32 inSz;
1230+
int ret;
1231+
1232+
extraSz = BuildDirectTcpipExtra("127.0.0.1", 8080, "127.0.0.1", 2222,
1233+
extra, sizeof(extra));
1234+
inSz = BuildChannelOpenPacket("direct-tcpip", 9, 0x4000, 0x8000,
1235+
extra, extraSz, in, sizeof(in));
1236+
1237+
InitChannelOpenHarness(&harness, in, inSz);
1238+
/* Intentionally do NOT register fwdCb */
1239+
1240+
ret = DoReceive(harness.ssh);
1241+
AssertChannelOpenFailResponse(&harness, ret);
1242+
1243+
FreeChannelOpenHarness(&harness);
1244+
}
12221245
#endif
12231246

12241247
#ifdef WOLFSSH_AGENT
@@ -1683,6 +1706,7 @@ int main(int argc, char** argv)
16831706
TestChannelOpenCallbackRejectSendsOpenFail();
16841707
#ifdef WOLFSSH_FWD
16851708
TestDirectTcpipRejectSendsOpenFail();
1709+
TestDirectTcpipNoFwdCbSendsOpenFail();
16861710
#endif
16871711
#ifdef WOLFSSH_AGENT
16881712
TestAgentChannelNullAgentSendsOpenFail();

0 commit comments

Comments
 (0)