diff mbox series

resolv: Fix tests by aligning hand crafted queries

Message ID 20210614234011.2215641-1-shorne@gmail.com
State New
Headers show
Series resolv: Fix tests by aligning hand crafted queries | expand

Commit Message

Stafford Horne June 14, 2021, 11:40 p.m. UTC
When testing OpenRISC I get a bus error in res_send.  This is due to the
buf being cast to a (HEADER *) and trying the res_send code trying to read
different bits of the HEADER struct including 16-bit id etc.

On OpenRISC reads of 16-bits and 32-bits from structures need to be 2
byte and 4 byte aligned, respectively.

To fix this we can align the hand crafted queries.
---
 resolv/tst-resolv-binary.c  | 2 +-
 resolv/tst-resolv-trustad.c | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/resolv/tst-resolv-binary.c b/resolv/tst-resolv-binary.c
index 44895a1baa..f76ae057c4 100644
--- a/resolv/tst-resolv-binary.c
+++ b/resolv/tst-resolv-binary.c
@@ -52,7 +52,7 @@  do_test (void)
 
   for (int b = 0; b <= 255; ++b)
     {
-      unsigned char query[] =
+      unsigned char query[] __attribute__ ((aligned)) =
         {
           b, b,                 /* Transaction ID.  */
           1, 0,                 /* Query with RD flag.  */
diff --git a/resolv/tst-resolv-trustad.c b/resolv/tst-resolv-trustad.c
index 74ee5db735..8d6989adb4 100644
--- a/resolv/tst-resolv-trustad.c
+++ b/resolv/tst-resolv-trustad.c
@@ -93,7 +93,8 @@  do_test (void)
   /* By default, the resolver is not trusted, and the AD bit is
      cleared.  */
 
-  static const unsigned char hand_crafted_query[] =
+  static const unsigned char hand_crafted_query[]
+			     __attribute__ ((aligned)) =
     {
      10, 11,                    /* Transaction ID.  */
      1, 0x20,                   /* Query with RD, AD flags.  */