* DNS endianness
@ 2014-09-22 16:53 Andrei Borzenkov
2014-09-23 19:07 ` Colin Watson
2015-05-07 15:02 ` Vladimir 'φ-coder/phcoder' Serbinenko
0 siblings, 2 replies; 3+ messages in thread
From: Andrei Borzenkov @ 2014-09-22 16:53 UTC (permalink / raw)
To: grub-devel
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;
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: DNS endianness
2014-09-22 16:53 DNS endianness Andrei Borzenkov
@ 2014-09-23 19:07 ` Colin Watson
2015-05-07 15:02 ` Vladimir 'φ-coder/phcoder' Serbinenko
1 sibling, 0 replies; 3+ messages in thread
From: Colin Watson @ 2014-09-23 19:07 UTC (permalink / raw)
To: grub-devel
On Mon, Sep 22, 2014 at 08:53:25PM +0400, Andrei Borzenkov wrote:
> 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.
The operations are precisely synonymous in all cases, so you should just
use whichever spelling is clearest.
--
Colin Watson [cjwatson@ubuntu.com]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: DNS endianness
2014-09-22 16:53 DNS endianness Andrei Borzenkov
2014-09-23 19:07 ` Colin Watson
@ 2015-05-07 15:02 ` Vladimir 'φ-coder/phcoder' Serbinenko
1 sibling, 0 replies; 3+ messages in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2015-05-07 15:02 UTC (permalink / raw)
To: The development of GNU GRUB
[-- Attachment #1: Type: text/plain, Size: 1936 bytes --]
It's purely code aesthetics but go ahead.
Andrei Borzenkov wrote:
> 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;
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 213 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-05-07 15:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-22 16:53 DNS endianness Andrei Borzenkov
2014-09-23 19:07 ` Colin Watson
2015-05-07 15:02 ` Vladimir 'φ-coder/phcoder' Serbinenko
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.