DNS endianness
This does not sound right ...
static grub_err_trecv_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?
grub-core/net/dns.c +3 -3
@@ -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;
Quoted 11 lines · Andrei Borzenkov
This does not sound right ...
static
grub_err_trecv_hook(grub_net_udp_socket_tsock__attribute__((unused)),
structgrub_net_buff*nb,
void*data_)
{
...
head = (structdns_header*)nb->data;
...
for (i = 0; i <grub_cpu_to_be16(head->qdcount); i++)
Quoted 4 lines
{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.
Signature · 1 line
Colin Watson [[email protected]]
It's purely code aesthetics but go ahead.
Quoted 55 lines · Andrei Borzenkov
This does not sound right ...
static
grub_err_trecv_hook(grub_net_udp_socket_tsock__attribute__((unused)),
structgrub_net_buff*nb,
void*data_)
{
...
head = (structdns_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?
grub-core/net/dns.c +3
-3@@ -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
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel