aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Lewycky <nlewycky@google.com>2015-04-16 11:15:58 -0700
committerNick Lewycky <nlewycky@google.com>2015-04-16 11:15:58 -0700
commite19fc0ea57ac535c6aa28b58655cfcabfcf738d8 (patch)
treed24c5412de4de65e61d24c1ee0578f40d96a040f
parent2963bd873faf3eb3be33cca3a2ef3401ec088962 (diff)
downloadglibc-e19fc0ea57ac535c6aa28b58655cfcabfcf738d8.tar.xz
glibc-e19fc0ea57ac535c6aa28b58655cfcabfcf738d8.zip
Change this offsetof computation to use c89 offsetof. Tested:
-rw-r--r--README.google4
-rw-r--r--socket/sys/un.h3
2 files changed, 6 insertions, 1 deletions
diff --git a/README.google b/README.google
index b35bb815a5..fc0d061381 100644
--- a/README.google
+++ b/README.google
@@ -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)
diff --git a/socket/sys/un.h b/socket/sys/un.h
index fc0ed39cd8..fdb6f944d4 100644
--- a/socket/sys/un.h
+++ b/socket/sys/un.h
@@ -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