Skip to content

Commit be2a421

Browse files
committed
[lldb] Fix SocketTest.DomainGetConnectURI on macOS by stripping more zeroes from getpeername result
Apparently macOS is padding the name result with several padding zeroes at the end. Just strip them all to pretend it's a C-string. Thanks to Pavel for suggesting this fix.
1 parent 7664508 commit be2a421

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

lldb/source/Host/posix/DomainSocket.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,7 @@ std::string DomainSocket::GetSocketName() const {
143143
llvm::StringRef name(saddr_un.sun_path + GetNameOffset(),
144144
sock_addr_len - offsetof(struct sockaddr_un, sun_path) -
145145
GetNameOffset());
146-
if (name.back() == '\0')
147-
name = name.drop_back();
146+
name = name.drop_while([](char c) { return c == '\0'; });
148147

149148
return name.str();
150149
}

0 commit comments

Comments
 (0)