On Sat, Nov 04, 2006 at 03:44:23PM +0100, Sjoerd Simons wrote:
> Package: pdns-server
> Version: 2.9.20-6
> Severity: important
> 
> Hi, 
> 
>   I noticed the SOA record of some of my zones were completely wrong
>   when served by pdns on my ARM machine. An x86 running with _exactly_
>   the same zones and config works fine though.
> 
>   I set the severity to important, but this makes pdns completely
>   unusable on ARM.. 

After some debugging i found out that this was caused by some unaligned
accesses. See http://www.nslu2-linux.org/wiki/Info/Alignment for more info.
Attached is a patch that fixes this issue

  Sjoerd
-- 
"The four building blocks of the universe are fire, water, gravel and vinyl."
                -- Dave Barry
#! /bin/sh /usr/share/dpatch/dpatch-run
## dpatch by Sjoerd Simons <[EMAIL PROTECTED]>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Fix unaligned access, which causes undefined behaviour on arm

@DPATCH@
diff -Naur pdns-2.9.20.orig/pdns/dnspacket.cc 
pdns-2.9.20.patched/pdns/dnspacket.cc
--- pdns-2.9.20.orig/pdns/dnspacket.cc  2006-11-08 10:29:25.000000000 +0100
+++ pdns-2.9.20.patched/pdns/dnspacket.cc       2006-11-08 10:30:55.000000000 
+0100
@@ -540,9 +540,9 @@
   
   string piece4=makeSoaHostmasterPiece(soadata.hostmaster);
 
-  char piece5[20];
+  uint32_t piece5[5 * sizeof(uint32_t)];
   
-  uint32_t *i_p=(uint32_t *)piece5;
+  uint32_t *i_p=piece5;
   
   uint32_t soaoffset=0;
   if(soadata.serial && (soaoffset=arg().asNum("soa-serial-offset")))
@@ -561,7 +561,7 @@
   stringbuffer.append(p,10);
   stringbuffer+=piece3;
   stringbuffer+=piece4;
-  stringbuffer.append(piece5,20);
+  stringbuffer.append((char *)piece5, 5 * sizeof(uint32_t));
   if(place==DNSResourceRecord::ANSWER)
     d.ancount++;
   else

Reply via email to