# HG changeset patch # User Matt Johnston # Date 1267271598 0 # Node ID 8c737cd7c1af86323ae32bcfc119cc3c77f548ba # Parent 69e98c45db7c5c8df8d0aea58fcc23739b29700a# Parent 44f486b7242725eb7d7a8c6143e43b6c9c9518f4 merge of '48fdaa8706d1acda35e9d564adc9a1fbc96c18c8' and '658fd03abd21e0da7c4c89b9fff9dc693c72daae' diff -r 44f486b72427 -r 8c737cd7c1af cli-runopts.c diff -r 44f486b72427 -r 8c737cd7c1af cli-tcpfwd.c diff -r 44f486b72427 -r 8c737cd7c1af svr-tcpfwd.c --- 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: diff -r 44f486b72427 -r 8c737cd7c1af tcp-accept.c --- 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); diff -r 44f486b72427 -r 8c737cd7c1af tcpfwd.h