On Sat, Nov 20, 2021 at 06:44:58PM +0100, Florian Obser wrote:

> On 2021-11-20 18:41 +01, Florian Obser <flor...@openbsd.org> wrote:
> > On 2021-11-20 18:19 +01, Florian Obser <flor...@openbsd.org> wrote:
> >
> >> +/*
> >> + * Clear AD flag in the answer.
> >> + */
> >> +static void
> >> +clear_ad(struct asr_result *ar)
> >> +{
> >> +  struct asr_dns_header   *h;
> >> +  uint16_t                 flags;
> >> +
> >> +  h = (struct asr_dns_header *)ar->ar_data;
> >> +  flags = ntohs(h->flags);
> >> +  flags &= ~(AD_MASK);
> >> +  h->flags = htons(flags);
> >> +}
> >> +
> >
> > btw. is it possible that this is not alligned correctly on sparc64?
> >
> > should be do something like (not even compile tested)
> >
> > static void
> > clear_ad(struct asr_result *ar)
> > {
> >     struct asr_dns_header    h;
> >
> >         memmove(&h, ar->ar_data, sizeof(h));
> >         h.flags = ntohs(h.flags);
> >         h.flags &= ~(AD_MASK);
> >         h.flags = htons(h.flags);
> >         memmove(ar->ar_data, &h, sizeof(h));
> > }
> >
> 
> memcpy obviously, I was distracted by the copious amount of memmove in
> asr code...

It is not needed to copy the "whole" header just to change the flags.
You could just copy out, modify and copy back the flags field only.

otoh, it's just 12 bytes, so no big deal.

        -Otto

Reply via email to