diff --git a/transport-native-unix-common/src/main/c/netty_unix_socket.c b/transport-native-unix-common/src/main/c/netty_unix_socket.c index 79c5e43ecb..3f04f4b174 100644 --- a/transport-native-unix-common/src/main/c/netty_unix_socket.c +++ b/transport-native-unix-common/src/main/c/netty_unix_socket.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -50,7 +51,7 @@ extern int accept4(int sockFd, struct sockaddr* addr, socklen_t* addrlen, int fl // macro to calculate the length of a sockaddr_un struct for a given path length. // see sys/un.h#SUN_LEN, this is modified to allow nul bytes -#define _UNIX_ADDR_LENGTH(path_len) (uintptr_t) (((struct sockaddr_un *) 0)->sun_path) + path_len +#define _UNIX_ADDR_LENGTH(path_len) ((uintptr_t) offsetof(struct sockaddr_un, sun_path) + (uintptr_t) path_len) static int nettyNonBlockingSocket(int domain, int type, int protocol) { #ifdef SOCK_NONBLOCK