From: Arran Cudbard-Bell Date: Fri, 5 Jun 2020 01:03:49 +0000 (-0500) Subject: Don't include sys/un.h in individual compilation units X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b7be9be5b3dfd22b4e66ee1886f496e6198ac1c3;p=thirdparty%2Ffreeradius-server.git Don't include sys/un.h in individual compilation units --- diff --git a/src/lib/util/socket.c b/src/lib/util/socket.c index 88972ea9cac..f852a193fe6 100644 --- a/src/lib/util/socket.c +++ b/src/lib/util/socket.c @@ -250,18 +250,6 @@ bool fr_socket_is_valid_proto(int proto) } #ifdef HAVE_SYS_UN_H -# include -/* - * The linux headers define the macro as: - * - * # define SUN_LEN(ptr) ((size_t) (((struct sockaddr_un *) 0)->sun_path) \ - * + strlen ((ptr)->sun_path)) - * - * Which trips UBSAN, because it sees an operation on a NULL pointer. - */ -# undef SUN_LEN -# define SUN_LEN(su) (sizeof(*(su)) - sizeof((su)->sun_path) + strlen((su)->sun_path)) - /** Open a Unix socket * * @note If the file doesn't exist then errno will be set to ENOENT. diff --git a/src/lib/util/socket.h b/src/lib/util/socket.h index e567ac367e5..e3a53ccd3d9 100644 --- a/src/lib/util/socket.h +++ b/src/lib/util/socket.h @@ -41,6 +41,20 @@ extern "C" { #include #include +#ifdef HAVE_SYS_UN_H +# include +/* + * The linux headers define the macro as: + * + * # define SUN_LEN(ptr) ((size_t) (((struct sockaddr_un *) 0)->sun_path) \ + * + strlen ((ptr)->sun_path)) + * + * Which trips UBSAN, because it sees an operation on a NULL pointer. + */ +# undef SUN_LEN +# define SUN_LEN(su) (sizeof(*(su)) - sizeof((su)->sun_path) + strlen((su)->sun_path)) +#endif + bool fr_socket_is_valid_proto(int proto); int fr_socket_client_unix(char const *path, bool async); int fr_socket_client_udp(fr_ipaddr_t *src_ipaddr, uint16_t *src_port, fr_ipaddr_t const *dst_ipaddr, diff --git a/src/modules/proto_control/proto_control_unix.c b/src/modules/proto_control/proto_control_unix.c index 60eb7f70809..dd4063a18d7 100644 --- a/src/modules/proto_control/proto_control_unix.c +++ b/src/modules/proto_control/proto_control_unix.c @@ -31,18 +31,12 @@ #include #include #include +#include #include #include #include "proto_control.h" -#ifdef HAVE_SYS_UN_H -#include -#ifndef SUN_LEN -#define SUN_LEN(su) (sizeof(*(su)) - sizeof((su)->sun_path) + strlen((su)->sun_path)) -#endif -#endif - #ifdef HAVE_SYS_STAT_H #include #endif