]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
nss_dns: Check for proper A/AAAA address alignment
authorFlorian Weimer <fweimer@redhat.com>
Thu, 16 May 2019 16:26:36 +0000 (18:26 +0200)
committerFlorian Weimer <fweimer@redhat.com>
Thu, 16 May 2019 16:27:37 +0000 (18:27 +0200)
ChangeLog
resolv/nss_dns/dns-host.c

index cb020262d97e99d4a6f4b2509721fbef2c78bb5e..b98bdc46644154ea7f19796aa1a5d883729c2b7a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+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
index 9c15f25f283ffd881dc209993c40085f7ec31cbb..9c40051aff0f17a4d4b8a44679258e1a84333d7a 100644 (file)
@@ -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;