[PATCH v3, resend] Fix misaligned accesses to fields in HEADER struct defined in <arpa/nameser_compat.h>
John David Anglin
dave.anglin@bell.net
Wed Mar 16 16:50:18 GMT 2022
On 2022-03-16 12:15 p.m., Andreas Schwab wrote:
> On Mär 15 2022, John David Anglin wrote:
>
>> diff --git a/resolv/res_mkquery.c b/resolv/res_mkquery.c
>> index 5bc5b41531..9b82c82157 100644
>> --- a/resolv/res_mkquery.c
>> +++ b/resolv/res_mkquery.c
>> @@ -193,6 +193,15 @@ context_mkquery_common (struct resolv_context *ctx,
>> return result;
>> }
>>
>> +/* The structure HEADER is normally aligned to a word boundary and its
>> + fields are accessed using word loads and stores. We need to access
>> + this structure when it is aligned on a byte boundary. This can cause
>> + problems on machines with strict alignment. So, we create a new
>> + typedef to reduce its alignment to one. This ensures the fields are
>> + accessed with byte loads and stores. */
>> +typedef HEADER __attribute__ ((__aligned__(1))) UHEADER;
>> +#define HEADER UHEADER
>> +
> The only use of HEADER below that point is in __res_nopt, and AFACS the
> only caller __res_context_query always uses aligned memory.
Yes, it appears the callers of __res_nopt always use aligned memory. I'll check if this hunk can
be removed.
--
John David Anglin dave.anglin@bell.net
More information about the Libc-alpha
mailing list