All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrei Borzenkov <arvidjaar@gmail.com>
To: grub-devel@gnu.org
Subject: DNS endianness
Date: Mon, 22 Sep 2014 20:53:25 +0400	[thread overview]
Message-ID: <20140922205325.132df618@opensuse.site> (raw)

This does not sound right ...

static grub_err_t
recv_hook (grub_net_udp_socket_t sock __attribute__ ((unused)),
           struct grub_net_buff *nb,
           void *data_)
{
...
  head = (struct dns_header *) nb->data;
...
  for (i = 0; i < grub_cpu_to_be16 (head->qdcount); i++)
    {

We sure want to convert *to* cpu, not *from* cpu here? Same in all
other places in this function.

Do I miss something obvious here? Or how about patch below?

diff --git a/grub-core/net/dns.c b/grub-core/net/dns.c
index 0b771fb..9d0c8fc 100644
--- a/grub-core/net/dns.c
+++ b/grub-core/net/dns.c
@@ -262,7 +262,7 @@ recv_hook (grub_net_udp_socket_t sock __attribute__ ((unused)),
       grub_netbuff_free (nb);
       return GRUB_ERR_NONE;
     }
-  for (i = 0; i < grub_cpu_to_be16 (head->qdcount); i++)
+  for (i = 0; i < grub_be_to_cpu16 (head->qdcount); i++)
     {
       if (ptr >= nb->tail)
 	{
@@ -277,7 +277,7 @@ recv_hook (grub_net_udp_socket_t sock __attribute__ ((unused)),
       ptr += 4;
     }
   *data->addresses = grub_malloc (sizeof ((*data->addresses)[0])
-				 * grub_cpu_to_be16 (head->ancount));
+				 * grub_be_to_cpu16 (head->ancount));
   if (!*data->addresses)
     {
       grub_errno = GRUB_ERR_NONE;
@@ -286,7 +286,7 @@ recv_hook (grub_net_udp_socket_t sock __attribute__ ((unused)),
     }
   reparse_ptr = ptr;
  reparse:
-  for (i = 0, ptr = reparse_ptr; i < grub_cpu_to_be16 (head->ancount); i++)
+  for (i = 0, ptr = reparse_ptr; i < grub_be_to_cpu16 (head->ancount); i++)
     {
       int ignored = 0;
       grub_uint8_t class;


             reply	other threads:[~2014-09-22 16:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-22 16:53 Andrei Borzenkov [this message]
2014-09-23 19:07 ` DNS endianness Colin Watson
2015-05-07 15:02 ` Vladimir 'φ-coder/phcoder' Serbinenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140922205325.132df618@opensuse.site \
    --to=arvidjaar@gmail.com \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.