[Pdns-dev] Re: [patch] dnspacket endian issue

Christof Meerwald cmeerw at web.de
Mon Sep 8 21:06:05 CEST 2003


On Mon, 8 Sep 2003 13:09:25 +0200, Norbert Sendetzky wrote:
> Here's a small patch to fix an endian problem in the getAnswers()=20
> function.

Have you checked (with a debugger or by adding debug output) that the
original code is actually wrong and that your patch fixes the problem?

getLong already takes care of byte-ordering issues on different platforms,
so there is no need to call ntohl.


> --- pdns-2.9.11.orig/pdns/dnspacket.cc	Thu Mar 27 11:40:40 2003
> +++ pdns-2.9.11/pdns/dnspacket.cc	Mon Sep  8 12:28:07 2003
> @@ -1217,11 +1217,11 @@
>        // explicitly copy the SOA values out of the packet to avoid 
>        // SPARC alignment issues.
>        
> -      rr.content+=" ";rr.content+=itoa(getLong( datapos+offset    ));
> -      rr.content+=" ";rr.content+=itoa(getLong( datapos+offset+4  ));
> -      rr.content+=" ";rr.content+=itoa(getLong( datapos+offset+8  ));
> -      rr.content+=" ";rr.content+=itoa(getLong( datapos+offset+12 ));
> -      rr.content+=" ";rr.content+=itoa(getLong( datapos+offset+16 ));
> +      rr.content += " "; rr.content += itoa( ntohl( getLong( datapos + offset ) ) );
> +      rr.content += " "; rr.content += itoa( ntohl( getLong( datapos + offset + 4 ) ) );
> +      rr.content += " "; rr.content += itoa( ntohl( getLong( datapos + offset + 8 ) ) );
> +      rr.content += " "; rr.content += itoa( ntohl( getLong( datapos + offset + 12 ) ) );
> +      rr.content += " "; rr.content += itoa( ntohl( getLong( datapos + offset + 16 ) ) );


bye, Christof

-- 
http://cmeerw.org                                 JID: cmeerw at jabber.at
mailto cmeerw at web.de


More information about the Pdns-dev mailing list