summaryrefslogtreecommitdiff
path: root/package/dropbear/patches/160-segfault_fwd_localhost.patch
blob: 05ae844c19d34e95476f40aa7ec0bdc3814efe90 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
http://wl500g.googlecode.com/svn/trunk/dropbear/011-fwd-all-segfault.patch
https://dev.openwrt.org/ticket/10339

--- a/svr-tcpfwd.c
+++ b/svr-tcpfwd.c
@@ -210,15 +210,13 @@ static int svr_remotetcpreq() {
 	tcpinfo->chantype = &svr_chan_tcpremote;
 	tcpinfo->tcp_type = forwarded;
 
-	if (!opts.listen_fwd_all 
-			|| (strcmp(tcpinfo->listenaddr, "localhost") == 0) ) {
-        // NULL means "localhost only"
-        tcpinfo->listenaddr = NULL;
-	}
-    else
-    {
-        tcpinfo->listenaddr = bindaddr;
-    }
+	if (!opts.listen_fwd_all || (strcmp(bindaddr, "localhost") == 0) ) {
+		// NULL means "localhost only"
+		tcpinfo->listenaddr = NULL;
+	}
+	else {
+		tcpinfo->listenaddr = bindaddr;
+	}
 
 	ret = listen_tcpfwd(tcpinfo);
 
--- a/tcp-accept.c
+++ b/tcp-accept.c
@@ -80,6 +80,9 @@ static void tcp_acceptor(struct Listener
 			addr = tcpinfo->listenaddr;
 			port = tcpinfo->listenport;
 		}
+		if (!addr) {
+			addr = "localhost";
+		}
 
 		buf_putstring(ses.writepayload, addr, strlen(addr));
 		buf_putint(ses.writepayload, port);