Skip to content

Commit 0ec578f

Browse files
Fix DoGlobalRequestFwd to reject the forwarding when no fwdCb is set
1 parent 9c8b4e8 commit 0ec578f

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/internal.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8496,16 +8496,24 @@ static int DoGlobalRequestFwd(WOLFSSH* ssh,
84968496
isCancel ? " cancel" : "", bindAddr, bindPort);
84978497
}
84988498

8499-
if (ret == WS_SUCCESS && wantReply) {
8500-
ret = SendGlobalRequestFwdSuccess(ssh, 1, bindPort);
8501-
}
8502-
85038499
if (ret == WS_SUCCESS) {
85048500
if (ssh->ctx->fwdCb) {
85058501
ret = ssh->ctx->fwdCb(isCancel ? WOLFSSH_FWD_REMOTE_CLEANUP :
85068502
WOLFSSH_FWD_REMOTE_SETUP,
85078503
ssh->fwdCbCtx, bindAddr, bindPort);
85088504
}
8505+
else {
8506+
WLOG(WS_LOG_WARN, "No forwarding callback set, rejecting request. "
8507+
"Set one with wolfSSH_CTX_SetFwdCb().");
8508+
ret = WS_UNIMPLEMENTED_E;
8509+
}
8510+
}
8511+
8512+
if (ret == WS_SUCCESS && wantReply) {
8513+
ret = SendGlobalRequestFwdSuccess(ssh, 1, bindPort);
8514+
}
8515+
else if (ret == WS_UNIMPLEMENTED_E && wantReply) {
8516+
SendGlobalRequestFwdSuccess(ssh, 0, 0);
85098517
}
85108518

85118519
if (bindAddr != NULL)

0 commit comments

Comments
 (0)