From 01cab14dfad656eb1d5f7e6a611a49a87c83b34e Mon Sep 17 00:00:00 2001 From: Radostin Stoyanov Date: Fri, 22 Feb 2019 18:04:32 +0000 Subject: [PATCH] util: Fix addr casting for IPv4/IPv6 in autobind When saddr.ss_family is AF_INET6 we should cast &saddr to (struct sockaddr_in6 *). Signed-off-by: Radostin Stoyanov Signed-off-by: Andrei Vagin --- criu/util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/criu/util.c b/criu/util.c index 6f6a6dde7..06c594ca9 100644 --- a/criu/util.c +++ b/criu/util.c @@ -1131,9 +1131,9 @@ int setup_tcp_server(char *type, char *addr, unsigned short *port) } if (saddr.ss_family == AF_INET6) { - (*port) = ntohs(((struct sockaddr_in *)&saddr)->sin_port); - } else if (saddr.ss_family == AF_INET) { (*port) = ntohs(((struct sockaddr_in6 *)&saddr)->sin6_port); + } else if (saddr.ss_family == AF_INET) { + (*port) = ntohs(((struct sockaddr_in *)&saddr)->sin_port); } pr_info("Using %u port\n", (*port));