Ahem, let's not try initialising a static with a non-constant initialiser.
authorjacob <jacob@cda61777-01e9-0310-a592-d414129be87e>
Mon, 1 Nov 2004 00:47:37 +0000 (00:47 +0000)
committerjacob <jacob@cda61777-01e9-0310-a592-d414129be87e>
Mon, 1 Nov 2004 00:47:37 +0000 (00:47 +0000)
Also, I'm pretty sure that adding a source address to a remote SSH-2 forwarding
can never have worked, since we added an address string to the packet twice in
that case. OpenSSH 3.4p1 certainly doesn't like it (`Server has disabled port
forwarding' debug message). Fixed (and OpenSSH is happier now).

git-svn-id: svn://svn.tartarus.org/sgt/putty@4727 cda61777-01e9-0310-a592-d414129be87e

ssh.c

diff --git a/ssh.c b/ssh.c
index d028974..08a0aff 100644 (file)
--- a/ssh.c
+++ b/ssh.c
@@ -5770,7 +5770,8 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen, int ispkt)
            }
            if (sport && dport) {
                /* Set up a description of the source port. */
-               static char *sportdesc = dupprintf("%.*s%.*s%.*s%.*s%d%.*s",
+               static char *sportdesc;
+               sportdesc = dupprintf("%.*s%.*s%.*s%.*s%d%.*s",
                        (int)(*saddr?strlen(saddr):0), *saddr?saddr:NULL,
                        (int)(*saddr?1:0), ":",
                        (int)(sserv ? strlen(sports) : 0), sports,
@@ -5823,12 +5824,13 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen, int ispkt)
                        ssh2_pkt_init(ssh, SSH2_MSG_GLOBAL_REQUEST);
                        ssh2_pkt_addstring(ssh, "tcpip-forward");
                        ssh2_pkt_addbool(ssh, 1);/* want reply */
-                       if (*saddr)
+                       if (*saddr) {
                            ssh2_pkt_addstring(ssh, saddr);
-                       if (ssh->cfg.rport_acceptall)
+                       } else if (ssh->cfg.rport_acceptall) {
                            ssh2_pkt_addstring(ssh, "0.0.0.0");
-                       else
+                       } else {
                            ssh2_pkt_addstring(ssh, "127.0.0.1");
+                       }
                        ssh2_pkt_adduint32(ssh, sport);
                        ssh2_pkt_send(ssh);