]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Change this offsetof computation to use c89 offsetof. Tested:
authorNick Lewycky <nlewycky@google.com>
Thu, 16 Apr 2015 18:15:58 +0000 (11:15 -0700)
committerNick Lewycky <nlewycky@google.com>
Thu, 16 Apr 2015 18:15:58 +0000 (11:15 -0700)
README.google
socket/sys/un.h

index b35bb815a5d1f2b06e13d235d037c2f7dd8b8327..fc0d0613817b99f0d965249dffe2eebb6943a41f 100644 (file)
@@ -429,3 +429,7 @@ stdio-common/tst-sscanf.c
 stdio-common/vfscanf.c
   For b/19289207, backport memory allocation fix for wscanf (PR16618)
   https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=5bd80bfe9ca0d955bfbbc002781bc7b01b6bcb06
+
+socket/sys/un.h
+  Replace null dereference in the SUN_LEN macro with offsetof.
+  (nlewycky, not yet upstream)
index fc0ed39cd8a69cc4cb53c5e020dfe9b296e56623..fdb6f944d43cdc6bd20f4a59df469eb11153251e 100644 (file)
@@ -34,10 +34,11 @@ struct sockaddr_un
 
 
 #ifdef __USE_MISC
+# include <stddef.h>           /* For offsetof.  */
 # 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