red-stream: Fix issue with SASL and no-Glibc

Using Unix sockets and no-Glibc C libraries (like Musl) getnameinfo
will fail causing SASL code to fail initialization.
Replicate Glibc behavior and report "localhost" as host and an
empty port string.

This fixes https://gitlab.freedesktop.org/spice/spice/-/issues/58.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
This commit is contained in:
Frediano Ziglio 2021-05-11 05:12:59 +01:00
parent 9376d5ed30
commit 3de587a76c

View File

@ -754,6 +754,11 @@ static char *addr_to_string(const char *format,
char serv[NI_MAXSERV];
int err;
// makes it work on no-glibc avoiding getnameinfo returning error
if (sa->ss_family == AF_UNIX) {
return g_strdup("localhost;");
}
if ((err = getnameinfo((struct sockaddr *)sa, salen,
host, sizeof(host),
serv, sizeof(serv),