From fb019d5c9df45c8a56a237fc98ca2d146b26dfa4 Mon Sep 17 00:00:00 2001 From: John Safranek Date: Fri, 16 Oct 2026 14:34:35 -0700 Subject: [PATCH] internal: check ssh in SendChannelTerminalResize It was the one channel sender that read ssh->defaultPeerChannelId without a NULL check. It now returns WS_BAD_ARGUMENT for a NULL ssh and logs entry and exit like its siblings. - add TestTerminalResizeNullSsh to regress.test Issue: F-14769 --- src/internal.c | 6 ++++++ tests/regress.c | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/src/internal.c b/src/internal.c index 5f430b55..d38cd480 100644 --- a/src/internal.c +++ b/src/internal.c @@ -24593,6 +24593,11 @@ int SendChannelTerminalResize(WOLFSSH* ssh, word32 columns, word32 rows, const char* cType = "window-change"; word32 typeSz = 0; + WLOG(WS_LOG_DEBUG, "Entering SendChannelTerminalResize()"); + + if (ssh == NULL) + ret = WS_BAD_ARGUMENT; + if (ret == WS_SUCCESS) { channel = ChannelFind(ssh, ssh->defaultPeerChannelId, WS_CHANNEL_ID_PEER); @@ -24641,6 +24646,7 @@ int SendChannelTerminalResize(WOLFSSH* ssh, word32 columns, word32 rows, if (ret == WS_SUCCESS) ret = wolfSSH_SendPacket(ssh); + WLOG(WS_LOG_DEBUG, "Leaving SendChannelTerminalResize(), ret = %d", ret); return ret; } diff --git a/tests/regress.c b/tests/regress.c index c0743894..fa6b8171 100644 --- a/tests/regress.c +++ b/tests/regress.c @@ -15394,6 +15394,12 @@ static void TestTerminalResizeBlockedAfterDisconnect(void) wolfSSH_free(ssh); wolfSSH_CTX_free(ctx); } + +static void TestTerminalResizeNullSsh(void) +{ + AssertIntEQ(SendChannelTerminalResize(NULL, 80, 24, 0, 0), + WS_BAD_ARGUMENT); +} #endif /* WOLFSSH_TERM && !NO_FILESYSTEM */ #endif /* !NO_WOLFSSH_CLIENT */ @@ -21087,6 +21093,7 @@ int main(int argc, char** argv) #if defined(WOLFSSH_TERM) && !defined(NO_FILESYSTEM) \ && !defined(NO_WOLFSSH_CLIENT) TestTerminalResizeBlockedAfterDisconnect(); + TestTerminalResizeNullSsh(); #endif #if !(defined(WOLFSSH_NO_RSA) && defined(WOLFSSH_NO_ECDSA_SHA2_NISTP256)) TestClientBuffersIdempotent();