Index: runtime/bin/socket_android.cc |
diff --git a/runtime/bin/socket_android.cc b/runtime/bin/socket_android.cc |
index 976efcf29fa05c3a73908e46106ffeb3057ee3cd..8ef4234b74d9fc7b156594167923f958f3ab6a4f 100644 |
--- a/runtime/bin/socket_android.cc |
+++ b/runtime/bin/socket_android.cc |
@@ -47,7 +47,10 @@ intptr_t Socket::Create(RawAddr addr) { |
fd = TEMP_FAILURE_RETRY(socket(addr.ss.ss_family, SOCK_STREAM, 0)); |
if (fd < 0) { |
- Log::PrintErr("Error Create: %s\n", strerror(errno)); |
+ const int kBufferSize = 1024; |
+ char error_message[kBufferSize]; |
+ strerror_r(errno, error_message, kBufferSize); |
+ Log::PrintErr("Error Create: %s\n", error_message); |
return -1; |
} |
@@ -121,7 +124,10 @@ intptr_t Socket::GetPort(intptr_t fd) { |
getsockname(fd, |
&raw.addr, |
&size))) { |
- Log::PrintErr("Error getsockname: %s\n", strerror(errno)); |
+ const int kBufferSize = 1024; |
+ char error_message[kBufferSize]; |
+ strerror_r(errno, error_message, kBufferSize); |
+ Log::PrintErr("Error getsockname: %s\n", error_message); |
return 0; |
} |
return SocketAddress::GetAddrPort(&raw); |
@@ -136,7 +142,10 @@ bool Socket::GetRemotePeer(intptr_t fd, char *host, intptr_t *port) { |
getpeername(fd, |
&raw.addr, |
&size))) { |
- Log::PrintErr("Error getpeername: %s\n", strerror(errno)); |
+ const int kBufferSize = 1024; |
+ char error_message[kBufferSize]; |
+ strerror_r(errno, error_message, kBufferSize); |
+ Log::PrintErr("Error getpeername: %s\n", error_message); |
return false; |
} |
const void* src; |
@@ -149,7 +158,10 @@ bool Socket::GetRemotePeer(intptr_t fd, char *host, intptr_t *port) { |
src, |
host, |
INET_ADDRSTRLEN) == NULL) { |
- Log::PrintErr("Error inet_ntop: %s\n", strerror(errno)); |
+ const int kBufferSize = 1024; |
+ char error_message[kBufferSize]; |
+ strerror_r(errno, error_message, kBufferSize); |
+ Log::PrintErr("Error inet_ntop: %s\n", error_message); |
return false; |
} |
*port = SocketAddress::GetAddrPort(&raw); |