[Lldb-commits] [lldb] r243118 - Bind to the loopback when we are expecting a connection from 127.0.0.1 so we don't set off firewall protections.
Greg Clayton
gclayton at apple.com
Fri Jul 24 09:55:00 PDT 2015
Author: gclayton
Date: Fri Jul 24 11:55:00 2015
New Revision: 243118
URL: http://llvm.org/viewvc/llvm-project?rev=243118&view=rev
Log:
Bind to the loopback when we are expecting a connection from 127.0.0.1 so we don't set off firewall protections.
<rdar://problem/17897318>
Modified:
lldb/trunk/source/Host/common/Socket.cpp
Modified: lldb/trunk/source/Host/common/Socket.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Socket.cpp?rev=243118&r1=243117&r2=243118&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/Socket.cpp (original)
+++ lldb/trunk/source/Host/common/Socket.cpp Fri Jul 24 11:55:00 2015
@@ -201,12 +201,12 @@ Error Socket::TcpConnect(llvm::StringRef
return error;
}
-Error Socket::TcpListen(
- llvm::StringRef host_and_port,
- bool child_processes_inherit,
- Socket *&socket,
- Predicate<uint16_t>* predicate,
- int backlog)
+Error
+Socket::TcpListen (llvm::StringRef host_and_port,
+ bool child_processes_inherit,
+ Socket *&socket,
+ Predicate<uint16_t>* predicate,
+ int backlog)
{
std::unique_ptr<Socket> listen_socket;
NativeSocket listen_sock = kInvalidSocketValue;
@@ -237,10 +237,19 @@ Error Socket::TcpListen(
if (!DecodeHostAndPort (host_and_port, host_str, port_str, port, &error))
return error;
- SocketAddress anyaddr;
- if (anyaddr.SetToAnyAddress (family, port))
+ SocketAddress bind_addr;
+ bool bind_addr_success = false;
+
+ // Only bind to the loopback address if we are expecting a connection from
+ // localhost to avoid any firewall issues.
+ if (host_str == "127.0.0.1")
+ bind_addr_success = bind_addr.SetToLocalhost (family, port);
+ else
+ bind_addr_success = bind_addr.SetToAnyAddress (family, port);
+
+ if (bind_addr_success)
{
- int err = ::bind (listen_sock, anyaddr, anyaddr.GetLength());
+ int err = ::bind (listen_sock, bind_addr, bind_addr.GetLength());
if (err == -1)
{
SetLastError (error);
More information about the lldb-commits
mailing list