From 937ff1a0af1813875f851987ca5c4ac833ca3c97 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 17 May 2017 10:27:31 -0700 Subject: [PATCH] Catch IPv4/IPv6 issues at compile time * src/process.c (connect_network_socket): Use verify, not eassert, so that any problems are caught at compile-time. Avoid dodgy cast by using a local var of the correct type. --- src/process.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/process.c b/src/process.c index ecb1b0ca6df..8180feaba9a 100644 --- a/src/process.c +++ b/src/process.c @@ -3430,11 +3430,11 @@ connect_network_socket (Lisp_Object proc, Lisp_Object addrinfos, /* The code below assumes the port is at the same offset and of the same width in both IPv4 and IPv6 structures, but the standards don't guarantee that, - so we have this assertion to make sure. */ - eassert ((offsetof (struct sockaddr_in, sin_port) - == offsetof (struct sockaddr_in6, sin6_port)) - && (sizeof (sa1.sin_port) - == sizeof (((struct sockaddr_in6 *) &sa1)->sin6_port))); + so verify it here. */ + struct sockaddr_in6 sa6; + verify ((offsetof (struct sockaddr_in, sin_port) + == offsetof (struct sockaddr_in6, sin6_port)) + && sizeof (sa1.sin_port) == sizeof (sa6.sin6_port)); #endif if (getsockname (s, (struct sockaddr *)&sa1, &len1) == 0) { -- 2.39.2