Skip to content
This repository was archived by the owner on Oct 20, 2023. It is now read-only.

Commit 9331bb3

Browse files
committed
Fix null-dereference in ssh2_channel_response.
In the SSH-2 connection layer, an outstanding_channel_request structure comes with a handler to be called back with the reply packet, when the other end sends one. But sometimes it doesn't - if the channel begins to close before the request has been replied to - in which case the handler function is called with a NULL packet pointer. The common ssh2_channel_response function that handles most of the client-side channel requests was not prepared to cope with that pointer being null. Fixed by making it handle a null return the same as CHANNEL_FAILURE. (cherry picked from commit e4b6a7e)
1 parent 464ab13 commit 9331bb3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

ssh2connection-client.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,11 @@ SshChannel *ssh2_serverside_agent_open(ConnectionLayer *cl, Channel *chan)
315315
static void ssh2_channel_response(
316316
struct ssh2_channel *c, PktIn *pkt, void *ctx)
317317
{
318-
chan_request_response(c->chan, pkt->type == SSH2_MSG_CHANNEL_SUCCESS);
318+
/* If pkt==NULL (because this handler has been called in response
319+
* to CHANNEL_CLOSE arriving while the request was still
320+
* outstanding), we treat that the same as CHANNEL_FAILURE. */
321+
chan_request_response(c->chan,
322+
pkt && pkt->type == SSH2_MSG_CHANNEL_SUCCESS);
319323
}
320324

321325
void ssh2channel_start_shell(SshChannel *sc, bool want_reply)

0 commit comments

Comments
 (0)