diff --git a/src/internal.c b/src/internal.c index d94037072..683f5097e 100644 --- a/src/internal.c +++ b/src/internal.c @@ -7767,7 +7767,7 @@ static int DoChannelRequest(WOLFSSH* ssh, word32 typeSz; char type[32]; byte wantReply; - int ret; + int ret, rej = 0; WLOG(WS_LOG_DEBUG, "Entering DoChannelRequest()"); @@ -7815,7 +7815,7 @@ static int DoChannelRequest(WOLFSSH* ssh, else if (WSTRNCMP(type, "shell", typeSz) == 0) { channel->sessionType = WOLFSSH_SESSION_SHELL; if (ssh->ctx->channelReqShellCb) { - ssh->ctx->channelReqShellCb(channel, ssh->channelReqCtx); + rej = ssh->ctx->channelReqShellCb(channel, ssh->channelReqCtx); } ssh->clientState = CLIENT_DONE; } @@ -7824,7 +7824,7 @@ static int DoChannelRequest(WOLFSSH* ssh, buf, len, &begin); channel->sessionType = WOLFSSH_SESSION_EXEC; if (ssh->ctx->channelReqExecCb) { - ssh->ctx->channelReqExecCb(channel, ssh->channelReqCtx); + rej = ssh->ctx->channelReqExecCb(channel, ssh->channelReqCtx); } ssh->clientState = CLIENT_DONE; @@ -7835,7 +7835,7 @@ static int DoChannelRequest(WOLFSSH* ssh, buf, len, &begin); channel->sessionType = WOLFSSH_SESSION_SUBSYSTEM; if (ssh->ctx->channelReqSubsysCb) { - ssh->ctx->channelReqSubsysCb(channel, ssh->channelReqCtx); + rej = ssh->ctx->channelReqSubsysCb(channel, ssh->channelReqCtx); } ssh->clientState = CLIENT_DONE; @@ -7971,7 +7971,11 @@ static int DoChannelRequest(WOLFSSH* ssh, if (wantReply) { int replyRet; - replyRet = SendChannelSuccess(ssh, channelId, (ret == WS_SUCCESS)); + if (rej) { + WLOG(WS_LOG_DEBUG, "Callback rejecting channel request."); + } + replyRet = SendChannelSuccess(ssh, channelId, + (ret == WS_SUCCESS && !rej)); if (replyRet != WS_SUCCESS) ret = replyRet; }