Add error verification in netbuff operations.
This commit is contained in:
parent
d6d205568f
commit
d855fbcf37
7 changed files with 38 additions and 19 deletions
|
@ -15,8 +15,10 @@ send_ethernet_packet (struct grub_net_network_level_interface *inf,
|
|||
grub_uint16_t ethertype)
|
||||
{
|
||||
struct etherhdr *eth;
|
||||
grub_err_t err;
|
||||
|
||||
grub_netbuff_push (nb, sizeof (*eth));
|
||||
if ((err = grub_netbuff_push (nb, sizeof (*eth))) != GRUB_ERR_NONE)
|
||||
return err;
|
||||
eth = (struct etherhdr *) nb->data;
|
||||
grub_memcpy (eth->dst, target_addr.mac, 6);
|
||||
grub_memcpy (eth->src, inf->hwaddress.mac, 6);
|
||||
|
@ -33,10 +35,12 @@ grub_net_recv_ethernet_packet (struct grub_net_buff *nb)
|
|||
struct llchdr *llch;
|
||||
struct snaphdr *snaph;
|
||||
grub_uint16_t type;
|
||||
grub_err_t err;
|
||||
|
||||
eth = (struct etherhdr *) nb->data;
|
||||
type = grub_be_to_cpu16 (eth->type);
|
||||
grub_netbuff_pull (nb, sizeof (*eth));
|
||||
if ((err = grub_netbuff_pull (nb, sizeof (*eth))) != GRUB_ERR_NONE)
|
||||
return err;
|
||||
|
||||
if (type <= 1500)
|
||||
{
|
||||
|
@ -45,7 +49,8 @@ grub_net_recv_ethernet_packet (struct grub_net_buff *nb)
|
|||
|
||||
if (llch->dsap == 0xaa && llch->ssap == 0xaa && llch->ctrl == 0x3)
|
||||
{
|
||||
grub_netbuff_pull (nb, sizeof (*llch));
|
||||
if ((err = grub_netbuff_pull (nb, sizeof (*llch))) != GRUB_ERR_NONE)
|
||||
return err;
|
||||
snaph = (struct snaphdr *) nb->data;
|
||||
type = snaph->type;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue