changeset 579:8c737cd7c1af

merge of '48fdaa8706d1acda35e9d564adc9a1fbc96c18c8' and '658fd03abd21e0da7c4c89b9fff9dc693c72daae'
author Matt Johnston <matt@ucc.asn.au>
date Sat, 27 Feb 2010 11:53:18 +0000
parents 69e98c45db7c (diff) 44f486b72427 (current diff)
children dd9947170fc8
files cli-runopts.c cli-tcpfwd.c tcpfwd.h
diffstat 2 files changed, 11 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/svr-tcpfwd.c	Sat Feb 27 11:51:19 2010 +0000
+++ b/svr-tcpfwd.c	Sat Feb 27 11:53:18 2010 +0000
@@ -206,11 +206,20 @@
 	tcpinfo = (struct TCPListener*)m_malloc(sizeof(struct TCPListener));
 	tcpinfo->sendaddr = NULL;
 	tcpinfo->sendport = 0;
-	tcpinfo->listenaddr = bindaddr;
 	tcpinfo->listenport = port;
 	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;
+    }
+
 	ret = listen_tcpfwd(tcpinfo);
 
 out:
--- a/tcp-accept.c	Sat Feb 27 11:51:19 2010 +0000
+++ b/tcp-accept.c	Sat Feb 27 11:53:18 2010 +0000
@@ -104,21 +104,13 @@
 	struct Listener *listener = NULL;
 	int nsocks;
 	char* errstring = NULL;
-	/* listen_spec = NULL indicates localhost */
-	const char* listen_spec = NULL;
 
 	TRACE(("enter listen_tcpfwd"))
 
 	/* first we try to bind, so don't need to do so much cleanup on failure */
 	snprintf(portstring, sizeof(portstring), "%d", tcpinfo->listenport);
 
-	/* a listenaddr of "" will indicate all interfaces */
-	if (opts.listen_fwd_all 
-			&& (strcmp(tcpinfo->listenaddr, "localhost") != 0) ) {
-		listen_spec = tcpinfo->listenaddr;
-	}
-
-	nsocks = dropbear_listen(listen_spec, portstring, socks, 
+	nsocks = dropbear_listen(tcpinfo->listenaddr, portstring, socks, 
 			DROPBEAR_MAX_SOCKS, &errstring, &ses.maxfd);
 	if (nsocks < 0) {
 		dropbear_log(LOG_INFO, "TCP forward failed: %s", errstring);