diff options
author | Florian Weimer <fweimer@redhat.com> | 2019-05-16 18:26:36 +0200 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2019-05-16 18:27:37 +0200 |
commit | 53bc5770aab40e57d95adc3dff771c975b2174e8 (patch) | |
tree | d1ff8f183fdc44ef4123814e1d2c16881754c8c9 | |
parent | ec255a97a22c0b46c111ff0f10be2beb9b5d9224 (diff) | |
download | glibc-53bc5770aab40e57d95adc3dff771c975b2174e8.tar glibc-53bc5770aab40e57d95adc3dff771c975b2174e8.tar.gz glibc-53bc5770aab40e57d95adc3dff771c975b2174e8.tar.bz2 glibc-53bc5770aab40e57d95adc3dff771c975b2174e8.zip |
nss_dns: Check for proper A/AAAA address alignment
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | resolv/nss_dns/dns-host.c | 11 |
2 files changed, 14 insertions, 2 deletions
@@ -1,5 +1,10 @@ 2019-05-16 Florian Weimer <fweimer@redhat.com> + * resolv/nss_dns/dns-host.c (getanswer_r): Be more explicit about + struct in_addr/struct in6_addr alignment. + +2019-05-16 Florian Weimer <fweimer@redhat.com> + * nis/nss_nis/nis-hosts.c (EXTRA_ARGS, EXTRA_ARGS_DECL): Remove flags argument. (LINE_PARSER): Do not map IPv4 addresses. diff --git a/resolv/nss_dns/dns-host.c b/resolv/nss_dns/dns-host.c index 9c15f25f28..9c40051aff 100644 --- a/resolv/nss_dns/dns-host.c +++ b/resolv/nss_dns/dns-host.c @@ -947,8 +947,15 @@ getanswer_r (struct resolv_context *ctx, linebuflen -= nn; } - linebuflen -= sizeof (align) - ((u_long) bp % sizeof (align)); - bp += sizeof (align) - ((u_long) bp % sizeof (align)); + /* Provide sufficient alignment for both address + families. */ + enum { align = 4 }; + _Static_assert ((align % __alignof__ (struct in_addr)) == 0, + "struct in_addr alignment"); + _Static_assert ((align % __alignof__ (struct in6_addr)) == 0, + "struct in6_addr alignment"); + linebuflen -= align - ((u_long) bp % align); + bp += align - ((u_long) bp % align); if (__glibc_unlikely (n > linebuflen)) goto too_small; |