From 78240cb228cb76ed8776cf3830d51131ab4452fa Mon Sep 17 00:00:00 2001 From: dtucker Date: Thu, 10 Nov 2022 23:03:10 +0000 Subject: [PATCH] Handle dynamic remote port forwarding in escape commandline's -R processing. bz#3499, ok djm@ --- usr.bin/ssh/clientloop.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/usr.bin/ssh/clientloop.c b/usr.bin/ssh/clientloop.c index 468c98d1980..1c2da07f909 100644 --- a/usr.bin/ssh/clientloop.c +++ b/usr.bin/ssh/clientloop.c @@ -1,4 +1,4 @@ -/* $OpenBSD: clientloop.c,v 1.381 2022/11/09 01:37:44 djm Exp $ */ +/* $OpenBSD: clientloop.c,v 1.382 2022/11/10 23:03:10 dtucker Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -837,8 +837,15 @@ process_cmdline(struct ssh *ssh) } logit("Canceled forwarding."); } else { - if (!parse_forward(&fwd, s, dynamic, remote)) { - logit("Bad forwarding specification."); + /* -R specs can be both dynamic or not, so check both. */ + if (remote) { + if (!parse_forward(&fwd, s, 0, remote) && + !parse_forward(&fwd, s, 1, remote)) { + logit("Bad remote forwarding specification."); + goto out; + } + } else if (!parse_forward(&fwd, s, dynamic, remote)) { + logit("Bad local forwarding specification."); goto out; } if (local || dynamic) { -- 2.20.1