mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-28 00:21:52 +03:00
Make padding in struct sockaddr_storage explicit [BZ #20111]
This avoids aliasing issues with GCC 6 in -fno-strict-aliasing mode. (With implicit padding, not all data is copied.) This change makes it explicit that struct sockaddr_storage is only 126 bytes large on m68k (unlike elsewhere, where we end up with the requested 128 bytes). The new test case makes sure that this does not happen on other architectures.
This commit is contained in:
@ -175,16 +175,16 @@ struct sockaddr
|
||||
|
||||
|
||||
/* Structure large enough to hold any socket address (with the historical
|
||||
exception of AF_UNIX). We reserve 128 bytes. */
|
||||
exception of AF_UNIX). */
|
||||
#define __ss_aligntype unsigned long int
|
||||
#define _SS_SIZE 128
|
||||
#define _SS_PADSIZE (_SS_SIZE - (2 * sizeof (__ss_aligntype)))
|
||||
#define _SS_PADSIZE \
|
||||
(_SS_SIZE - __SOCKADDR_COMMON_SIZE - sizeof (__ss_aligntype))
|
||||
|
||||
struct sockaddr_storage
|
||||
{
|
||||
__SOCKADDR_COMMON (ss_); /* Address family, etc. */
|
||||
__ss_aligntype __ss_align; /* Force desired alignment. */
|
||||
char __ss_padding[_SS_PADSIZE];
|
||||
__ss_aligntype __ss_align; /* Force desired alignment. */
|
||||
};
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user