summaryrefslogtreecommitdiffstats
path: root/lldb
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2019-04-08 21:58:36 +0000
committerAdrian Prantl <aprantl@apple.com>2019-04-08 21:58:36 +0000
commit1a0c0ffa9db515b9129b1086cdcf308ff342a519 (patch)
treed526f3b8b0cd981d1314080118257061bcc53343 /lldb
parent941f247d30c447903107aa614ea46fb1e4019698 (diff)
downloadbcm5719-llvm-1a0c0ffa9db515b9129b1086cdcf308ff342a519.tar.gz
bcm5719-llvm-1a0c0ffa9db515b9129b1086cdcf308ff342a519.zip
Fix a stack buffer overflow found by ASAN.
llvm::StringRef host_and_port is not guaranteed to be null-terminated. Generally, it is not safe at all to convert a StringRef into a char * by calling data() on it. <rdar://problem/49698580> llvm-svn: 357948
Diffstat (limited to 'lldb')
-rw-r--r--lldb/source/Host/common/Socket.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/lldb/source/Host/common/Socket.cpp b/lldb/source/Host/common/Socket.cpp
index 70502ebe3bf..6b9cb480067 100644
--- a/lldb/source/Host/common/Socket.cpp
+++ b/lldb/source/Host/common/Socket.cpp
@@ -124,7 +124,7 @@ Status Socket::TcpConnect(llvm::StringRef host_and_port,
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_COMMUNICATION));
if (log)
log->Printf("Socket::%s (host/port = %s)", __FUNCTION__,
- host_and_port.data());
+ host_and_port.str().c_str());
Status error;
std::unique_ptr<Socket> connect_socket(
@@ -144,7 +144,7 @@ Status Socket::TcpListen(llvm::StringRef host_and_port,
Predicate<uint16_t> *predicate, int backlog) {
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION));
if (log)
- log->Printf("Socket::%s (%s)", __FUNCTION__, host_and_port.data());
+ log->Printf("Socket::%s (%s)", __FUNCTION__, host_and_port.str().c_str());
Status error;
std::string host_str;
@@ -184,7 +184,7 @@ Status Socket::UdpConnect(llvm::StringRef host_and_port,
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION));
if (log)
log->Printf("Socket::%s (host/port = %s)", __FUNCTION__,
- host_and_port.data());
+ host_and_port.str().c_str());
return UDPSocket::Connect(host_and_port, child_processes_inherit, socket);
}
@@ -275,7 +275,8 @@ bool Socket::DecodeHostAndPort(llvm::StringRef host_and_port,
// port is too large
if (error_ptr)
error_ptr->SetErrorStringWithFormat(
- "invalid host:port specification: '%s'", host_and_port.data());
+ "invalid host:port specification: '%s'",
+ host_and_port.str().c_str());
return false;
}
}
@@ -293,7 +294,7 @@ bool Socket::DecodeHostAndPort(llvm::StringRef host_and_port,
if (error_ptr)
error_ptr->SetErrorStringWithFormat("invalid host:port specification: '%s'",
- host_and_port.data());
+ host_and_port.str().c_str());
return false;
}
OpenPOWER on IntegriCloud