[PATCH] Make padding in struct sockaddr_storage explicit [BZ #20111]

Florian Weimer fweimer@redhat.com
Mon May 23 08:57:00 GMT 2016


On 05/23/2016 10:07 AM, Andreas Schwab wrote:
> Florian Weimer <fweimer@redhat.com> writes:
>
>> diff --git a/sysdeps/unix/sysv/linux/bits/socket.h b/sysdeps/unix/sysv/linux/bits/socket.h
>> index 0581c79..8fbb6be 100644
>> --- a/sysdeps/unix/sysv/linux/bits/socket.h
>> +++ b/sysdeps/unix/sysv/linux/bits/socket.h
>> @@ -158,16 +158,15 @@ 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)))
>
> _SS_PADSIZE needs to be updated here as well.  Otherwise, looks ok.
>
> Andreas.

Great catch, thanks.

I added some more tests to cover this (the implicit padding was outside 
the part covered by struct sockaddr_in, so the bug wasn't visible 
before).  I realized that our test harness does not deal well with 
compilation failures, so I replaced the _Static_asserts with a run-time 
check.

I'm attaching what I'm going to commit later.

Florian

-------------- next part --------------
A non-text attachment was scrubbed...
Name: bug20111.patch
Type: text/x-patch
Size: 12426 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20160523/16f961d0/attachment.bin>


More information about the Libc-alpha mailing list