From nobody@FreeBSD.org  Sun Sep 23 02:35:00 2012
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 12736106564A
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 23 Sep 2012 02:35:00 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id F21518FC0A
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 23 Sep 2012 02:34:59 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.5/8.14.5) with ESMTP id q8N2Yxb5089695
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 23 Sep 2012 02:34:59 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.5/8.14.5/Submit) id q8N2Yxq1089694;
	Sun, 23 Sep 2012 02:34:59 GMT
	(envelope-from nobody)
Message-Id: <201209230234.q8N2Yxq1089694@red.freebsd.org>
Date: Sun, 23 Sep 2012 02:34:59 GMT
From: HIROSHI OOTA <nil@mad.dog.cx>
To: freebsd-gnats-submit@FreeBSD.org
Subject: incorrect port fowarding with server allocated port
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         171882
>Category:       bin
>Synopsis:       incorrect port fowarding with server allocated port
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Sep 23 02:40:08 UTC 2012
>Closed-Date:    
>Last-Modified:  Sun Sep 23 14:10:13 UTC 2012
>Originator:     HIROSHI OOTA
>Release:        10-current
>Organization:
>Environment:
FreeBSD xxx 10.0-CURRENT FreeBSD 10.0-CURRENT #165 r233752: Sun Apr  1 15:27:13 JST 2012     root  amd64
>Description:
SSH standard supports server allocated port.
We can use the capability the ssh option -R 0:host:hostport.
But, I specify it multiple, all  port would be fowarded to the first port.
>How-To-Repeat:

term1$ ssh -v -R 0:localhost:23 -R 0:localhost:25 -R 0:127.0.0.1:80 -N
debug1: remote forward success for: listen 0, connect 127.0.0.1:21
Allocated port 41791 for remote forward to 127.0.0.1:21
debug1: remote forward success for: listen 0, connect 127.0.0.1:25
Allocated port 23513 for remote forward to 127.0.0.1:25
debug1: remote forward success for: listen 0, connect 127.0.0.1:80
Allocated port 59246 for remote forward to 127.0.0.1:80

term2$ telnet localhost 23513
Trying ::1...
Connected to localhost.
Escape character is '^]'.
220 xxx FTP server (Version xxx) ready.

term2$ telnet localhost 59246
Trying ::1...
Connected to localhost.
Escape character is '^]'.
220 xxx FTP server (Version xxx) ready.

these ports should be forwaded to 25(smtp) and 80(http), not 21(ftp).
>Fix:


>Release-Note:
>Audit-Trail:

From: "HIROSHI OOTA" <nil@mad.dog.cx>
To: bug-followup@freebsd.org, nil@mad.dog.cx
Cc:  
Subject: Re: bin/171882: incorrect port fowarding with server allocated port
Date: Sun, 23 Sep 2012 21:39:12 +0900

 This problem was corrected in OpenSSH V6.1.

From: "HIROSHI OOTA" <nil@mad.dog.cx>
To: bug-followup@freebsd.org, nil@mad.dog.cx
Cc:  
Subject: Re: bin/171882: incorrect port fowarding with server allocated port
Date: Sun, 23 Sep 2012 23:00:00 +0900

 I tested under newest source. but it does not run correctly.
 The flags for datafellows is conflicted.
 
 Index: /usr/src/crypto/openssh/compat.h
 ===================================================================
 --- /usr/src/crypto/openssh/compat.h    (revision 240847)
 +++ /usr/src/crypto/openssh/compat.h    (working copy)
 @@ -60,7 +60,7 @@
   #define SSH_BUG_RFWD_ADDR      0x02000000
   #define SSH_NEW_OPENSSH                0x04000000
   #define SSH_BUG_DYNAMIC_RPORT  0x08000000
 -#define SSH_BUG_LARGEWINDOW    0x08000000
 +#define SSH_BUG_LARGEWINDOW    0x10000000
 
   void     enable_compat13(void);
   void     enable_compat20(void);
>Unformatted:
