about summary refs log tree commit diff
path: root/socket
diff options
context:
space:
mode:
authorAndreas Schwab <schwab@suse.de>2022-09-19 10:10:09 +0200
committerAndreas Schwab <schwab@suse.de>2022-10-10 09:30:26 +0200
commitc15318bfc5499d835c434a4d98b688aa2d928412 (patch)
tree58e935f8fff70d4d1c17cf625edca2203f2b4a43 /socket
parent954b8f38958de72c4712088735eb175118f17b51 (diff)
downloadglibc-c15318bfc5499d835c434a4d98b688aa2d928412.tar.gz
glibc-c15318bfc5499d835c434a4d98b688aa2d928412.tar.xz
glibc-c15318bfc5499d835c434a4d98b688aa2d928412.zip
socket: Use offsetof in SUN_LEN (bug 29578)
Use offsetof instead of its traditional expansion in the definition of the
SUN_LEN macro, to avoid a warning from the undefined behaviour sanitizer.
Diffstat (limited to 'socket')
-rw-r--r--socket/sys/un.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/socket/sys/un.h b/socket/sys/un.h
index 454eafebc9..2b11300e28 100644
--- a/socket/sys/un.h
+++ b/socket/sys/un.h
@@ -34,10 +34,11 @@ struct sockaddr_un
 
 
 #ifdef __USE_MISC
+# include <stddef.h>
 # include <string.h>		/* For prototype of `strlen'.  */
 
 /* Evaluate to actual length of the `sockaddr_un' structure.  */
-# define SUN_LEN(ptr) ((size_t) (((struct sockaddr_un *) 0)->sun_path)	      \
+# define SUN_LEN(ptr) (offsetof (struct sockaddr_un, sun_path)		      \
 		      + strlen ((ptr)->sun_path))
 #endif