]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Don't include sys/un.h in individual compilation units
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Fri, 5 Jun 2020 01:03:49 +0000 (20:03 -0500)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Fri, 5 Jun 2020 01:03:49 +0000 (20:03 -0500)
src/lib/util/socket.c
src/lib/util/socket.h
src/modules/proto_control/proto_control_unix.c

index 88972ea9cac77304be6b959f46db5125a9f66243..f852a193fe6998dbfa345567730e1f8e25cbf95a 100644 (file)
@@ -250,18 +250,6 @@ bool fr_socket_is_valid_proto(int proto)
 }
 
 #ifdef HAVE_SYS_UN_H
-#  include <sys/un.h>
-/*
- *  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.
index e567ac367e5c7132f3baa8911274cab8d49e3965..e3a53ccd3d94ad1c20ab871aed4ff5978d59dd2e 100644 (file)
@@ -41,6 +41,20 @@ extern "C" {
 #include <string.h>
 #include <sys/time.h>
 
+#ifdef HAVE_SYS_UN_H
+#  include <sys/un.h>
+/*
+ *  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,
index 60eb7f708094920663640ca94286d88c5a030cd4..dd4063a18d7a8f8eb46fc700b83b265e7959cf44 100644 (file)
 #include <freeradius-devel/server/protocol.h>
 #include <freeradius-devel/util/debug.h>
 #include <freeradius-devel/util/fopencookie.h>
+#include <freeradius-devel/util/socket.h>
 #include <freeradius-devel/util/trie.h>
 #include <netdb.h>
 
 #include "proto_control.h"
 
-#ifdef HAVE_SYS_UN_H
-#include <sys/un.h>
-#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 <sys/stat.h>
 #endif