arp, icmp: Fix handling in case of oversized or invalid packets.

This restrict ARP handling to MAC and IP addresses but in practice we need
only this case anyway and other cases are very rar if exist at all. It makes
code much simpler and less error-prone.
This commit is contained in:
Vladimir Serbinenko 2015-03-20 21:14:23 +01:00
parent 5974d4ba65
commit 63034d3261
4 changed files with 90 additions and 86 deletions

View file

@ -97,6 +97,26 @@ grub_netbuff_alloc (grub_size_t len)
return nb;
}
struct grub_net_buff *
grub_netbuff_make_pkt (grub_size_t len)
{
struct grub_net_buff *nb;
grub_err_t err;
nb = grub_netbuff_alloc (len + 512);
if (!nb)
return NULL;
err = grub_netbuff_reserve (nb, len + 512);
if (err)
goto fail;
err = grub_netbuff_push (nb, len);
if (err)
goto fail;
return nb;
fail:
grub_netbuff_free (nb);
return NULL;
}
void
grub_netbuff_free (struct grub_net_buff *nb)
{