Boris Tonofa
2025-Jun-20 19:28 UTC
[PATCH] mux: fix incorrect return value check in local forward cancellation
Hi, This patch fixes a logic error in mux_master_process_close_fwd(). channel_cancel_lport_listener() returns 1 on success and 0 on failure. The previous code incorrectly checked for `== -1`, a value the function never returns, so failure was not detected and the "port not found" error message was never shown when cancelling dynamic or local port forwards. The patch applies cleanly to current master and all GitHub CI jobs are green (see mirror PR): https://github.com/openssh/openssh-portable/pull/577 If merged, could you please keep the author line From: Boris Tonofa <b.tonofa at ideco.ru> in the commit message? My company would appreciate the attribution. Thanks for your time and review. Best regards, Boris From 41aacbdbf107bebae150a46bd098d4ed1f379019 Mon Sep 17 00:00:00 2001 From: Boris Tonofa <b.tonofa at ideco.ru> Date: Fri, 20 Jun 2025 19:22:14 +0300 Subject: [PATCH] mux: fix incorrect return value check in local forward cancellation channel_cancel_lport_listener() returns 1 on success and 0 on failure. The previous code incorrectly checked for `== -1`, a value the function never returns, so failure was not detected and the "port not found" error message was never shown when cancelling dynamic or local port forwards. --- mux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mux.c b/mux.c index 415024f74..ad40b4489 100644 --- a/mux.c +++ b/mux.c @@ -931,7 +931,7 @@ mux_master_process_close_fwd(struct ssh *ssh, u_int rid, } else { /* local and dynamic forwards */ /* Ditto */ if (channel_cancel_lport_listener(ssh, &fwd, fwd.connect_port, - &options.fwd_opts) == -1) + &options.fwd_opts) != 1) error_reason = "port not found"; } -- 2.47.0
Damien Miller
2025-Jul-04 00:21 UTC
[PATCH] mux: fix incorrect return value check in local forward cancellation
On Fri, 20 Jun 2025, Boris Tonofa wrote:> Hi, > > This patch fixes a logic error in mux_master_process_close_fwd(). > > channel_cancel_lport_listener() returns 1 on success and 0 on failure. > The previous code incorrectly checked for `== -1`, a value the function > never returns, so failure was not detected and the "port not found" > error message was never shown when cancelling dynamic or local port > forwards. > > The patch applies cleanly to current master and all GitHub CI jobs are > green (see mirror PR): > https://github.com/openssh/openssh-portable/pull/577 > > If merged, could you please keep the author line > From: Boris Tonofa <b.tonofa at ideco.ru> > in the commit message? My company would appreciate the attribution.Thanks for the fix, here's what I committed: Author: djm at openbsd.org <djm at openbsd.org> Date: Fri Jul 4 00:17:55 2025 +0000 upstream: mux: fix incorrect return value check in local forward cancellation channel_cancel_lport_listener() returns 1 on success and 0 on failure. The previous code incorrectly checked for `== -1`, a value the function never returns, so failure was not detected and the "port not found" error message was never shown when cancelling dynamic or local port forwards. From: Boris Tonofa <b.tonofa at ideco.ru> OpenBSD-Commit-ID: 3e9d2252a4d0bd318d4f25e2b518afb44acea170 Hope this is okay. -d