Add error verification in netbuff operations.

This commit is contained in:
Manoel R. Abranches 2011-06-18 20:20:53 -03:00
parent d6d205568f
commit d855fbcf37
7 changed files with 38 additions and 19 deletions

View file

@ -39,6 +39,7 @@ grub_net_arp_resolve (struct grub_net_network_level_interface *inf,
struct arphdr *arp_header;
grub_net_link_level_address_t target_hw_addr;
char *aux, arp_data[128];
grub_err_t err;
int i;
/* Check cache table. */
@ -52,9 +53,11 @@ grub_net_arp_resolve (struct grub_net_network_level_interface *inf,
nb.head = arp_data;
nb.end = arp_data + sizeof (arp_data);
grub_netbuff_clear (&nb);
grub_netbuff_reserve (&nb, 128);
grub_netbuff_push (&nb, sizeof (*arp_header) + 2 * (6 + 4));
if ((err = grub_netbuff_push (&nb, sizeof (*arp_header) + 2 * (6 + 4))) != GRUB_ERR_NONE)
return err;
arp_header = (struct arphdr *) nb.data;
arp_header->hrd = grub_cpu_to_be16 (GRUB_NET_ARPHRD_ETHERNET);
arp_header->pro = grub_cpu_to_be16 (GRUB_NET_ETHERTYPE_IP);