summaryrefslogtreecommitdiffstats
path: root/lldb/source/Host/common
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2015-07-24 16:55:00 +0000
committerGreg Clayton <gclayton@apple.com>2015-07-24 16:55:00 +0000
commitfceca9b53955e3e28bedc97fbcae4ec61c61a2d1 (patch)
tree90d3b20d2074b89bec7bfcacd0152904b2a131b0 /lldb/source/Host/common
parentfa8e3a551fed5111032e2292353d9888f944f5ef (diff)
downloadbcm5719-llvm-fceca9b53955e3e28bedc97fbcae4ec61c61a2d1.tar.gz
bcm5719-llvm-fceca9b53955e3e28bedc97fbcae4ec61c61a2d1.zip
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> llvm-svn: 243118
Diffstat (limited to 'lldb/source/Host/common')
-rw-r--r--lldb/source/Host/common/Socket.cpp27
1 files changed, 18 insertions, 9 deletions
diff --git a/lldb/source/Host/common/Socket.cpp b/lldb/source/Host/common/Socket.cpp
index 6620dab123b..37b6cd5aaa7 100644
--- a/lldb/source/Host/common/Socket.cpp
+++ b/lldb/source/Host/common/Socket.cpp
@@ -201,12 +201,12 @@ Error Socket::TcpConnect(llvm::StringRef host_and_port, bool child_processes_inh
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);
OpenPOWER on IntegriCloud