From 49a15d1f644b22093ec95a97745b790ef2e3285f Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Feb 13 2016 12:34:31 +0000 Subject: Resolves: #1306511 Support aliasing with struct sockaddr pointers. --- diff --git a/glibc-rh1306511.patch b/glibc-rh1306511.patch new file mode 100644 index 0000000..7239ced --- /dev/null +++ b/glibc-rh1306511.patch @@ -0,0 +1,67 @@ +commit 520dcf39f7b78a3b1db93c9be6a1c120eda699cd +Author: Florian Weimer +Date: Fri Feb 12 17:04:34 2016 +0100 + + bits/socket.h: Define struct sockaddr with may_alias attribute [BZ #19622] + + As suggested by Marek Polacek. + + Using struct sockaddr with aliasing violations is quite common, and the + POSIX interfaces more or less encourage it. + +diff --git a/bits/socket.h b/bits/socket.h +index ab9f242..666842b 100644 +--- a/bits/socket.h ++++ b/bits/socket.h +@@ -144,7 +144,7 @@ enum __socket_type + #include + + /* Structure describing a generic socket address. */ +-struct sockaddr ++struct __attribute_may_alias__ sockaddr + { + __SOCKADDR_COMMON (sa_); /* Common data: address family and length. */ + char sa_data[14]; /* Address data. */ +diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h +index 7fd4154..aee6ae3 100644 +--- a/misc/sys/cdefs.h ++++ b/misc/sys/cdefs.h +@@ -407,6 +407,12 @@ + [!!sizeof (struct { int __error_if_negative: (expr) ? 2 : -1; })] + #endif + ++#if __GNUC_PREREQ (4,0) ++# define __attribute_may_alias__ __attribute__ ((__may_alias__)) ++#else ++# define __attribute_may_alias__ ++#endif ++ + #include + + #if defined __LONG_DOUBLE_MATH_OPTIONAL && defined __NO_LONG_DOUBLE_MATH +diff --git a/sysdeps/mach/hurd/bits/socket.h b/sysdeps/mach/hurd/bits/socket.h +index 02c5dac..bc26a28 100644 +--- a/sysdeps/mach/hurd/bits/socket.h ++++ b/sysdeps/mach/hurd/bits/socket.h +@@ -148,7 +148,7 @@ enum __socket_type + #include + + /* Structure describing a generic socket address. */ +-struct sockaddr ++struct __attribute_may_alias__ sockaddr + { + __SOCKADDR_COMMON (sa_); /* Common data: address family and length. */ + char sa_data[14]; /* Address data. */ +diff --git a/sysdeps/unix/sysv/linux/bits/socket.h b/sysdeps/unix/sysv/linux/bits/socket.h +index 0581c79..a1fc921 100644 +--- a/sysdeps/unix/sysv/linux/bits/socket.h ++++ b/sysdeps/unix/sysv/linux/bits/socket.h +@@ -150,7 +150,7 @@ typedef __socklen_t socklen_t; + #include + + /* Structure describing a generic socket address. */ +-struct sockaddr ++struct __attribute_may_alias__ sockaddr + { + __SOCKADDR_COMMON (sa_); /* Common data: address family and length. */ + char sa_data[14]; /* Address data. */ diff --git a/glibc.spec b/glibc.spec index 3857139..9b7edd9 100644 --- a/glibc.spec +++ b/glibc.spec @@ -294,6 +294,7 @@ Patch2035: glibc-nsswitch-Add-group-merging-support.patch Patch2036: glibc-gcc-PR69537.patch Patch2037: glibc-isinf-cxx11.patch +Patch2038: glibc-rh1306511.patch ############################################################################## # @@ -689,6 +690,7 @@ cat /proc/meminfo %patch2035 -p1 %patch2036 -p1 %patch2037 -p1 +%patch2038 -p1 ############################################################################## # %%prep - Additional prep required... @@ -1957,6 +1959,7 @@ rm -f *.filelist* %changelog * Sat Feb 13 2016 Florian Weimer - 2.22.90-34 - Auto-sync with upstream master. +- Support aliasing with struct sockaddr pointers (#1306511). * Tue Feb 09 2016 Carlos O'Donell - 2.22.90-33 - Use --with-cpu=power8 for ppc64le default runtime (#1227361).