From: Pierre Ossman Date: Fri, 13 Jan 2023 10:15:36 +0000 (+0100) Subject: Better fallback for missing peer address X-Git-Tag: v1.13.90~87^2~19 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=334398153b605ebeadbff46cc63ac0c0d30748da;p=tigervnc.git Better fallback for missing peer address A blank string might be very confusing, depending on where this will be used. Let's give something more visible back in the cases where we cannot get the proper name for the peer. --- diff --git a/common/network/TcpSocket.cxx b/common/network/TcpSocket.cxx index 5241d94a..74143a40 100644 --- a/common/network/TcpSocket.cxx +++ b/common/network/TcpSocket.cxx @@ -217,7 +217,7 @@ const char* TcpSocket::getPeerAddress() { if (getpeername(getFd(), &sa.u.sa, &sa_size) != 0) { vlog.error("unable to get peer name for socket"); - return ""; + return "(N/A)"; } if (sa.u.sa.sa_family == AF_INET6) { @@ -231,7 +231,7 @@ const char* TcpSocket::getPeerAddress() { NI_NUMERICHOST); if (ret != 0) { vlog.error("unable to convert peer name to a string"); - return ""; + return "(N/A)"; } strcat(buffer, "]"); @@ -245,7 +245,7 @@ const char* TcpSocket::getPeerAddress() { name = inet_ntoa(sa.u.sin.sin_addr); if (name == NULL) { vlog.error("unable to convert peer name to a string"); - return ""; + return "(N/A)"; } return name;