* grub-core/net/tftp.c (tftp_receive): Silently discard too short

packets rather than raising an error.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2012-02-12 19:11:06 +01:00
parent 59bfe502c9
commit 0cf69874ee
2 changed files with 14 additions and 5 deletions

View file

@ -1,3 +1,8 @@
2012-02-12 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/net/tftp.c (tftp_receive): Silently discard too short
packets rather than raising an error.
2012-02-12 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/loader/xnu.c (grub_xnu_writetree_toheap_real): Avoid set

View file

@ -160,7 +160,10 @@ tftp_receive (grub_net_udp_socket_t sock __attribute__ ((unused)),
grub_uint8_t *ptr;
if (nb->tail - nb->data < (grub_ssize_t) sizeof (tftph->opcode))
return grub_error (GRUB_ERR_OUT_OF_RANGE, "TFTP packet too small");
{
grub_dprintf ("tftp", "TFTP packet too small\n");
return GRUB_ERR_NONE;
}
tftph = (struct tftphdr *) nb->data;
switch (grub_be_to_cpu16 (tftph->opcode))
@ -184,13 +187,14 @@ tftp_receive (grub_net_udp_socket_t sock __attribute__ ((unused)),
grub_netbuff_free (nb);
err = ack (data->sock, 0);
grub_error_save (&data->save_err);
if (err)
return err;
return GRUB_ERR_NONE;
case TFTP_DATA:
if (nb->tail - nb->data < (grub_ssize_t) (sizeof (tftph->opcode)
+ sizeof (tftph->u.data.block)))
return grub_error (GRUB_ERR_OUT_OF_RANGE, "TFTP packet too small");
{
grub_dprintf ("tftp", "TFTP packet too small\n");
return GRUB_ERR_NONE;
}
err = ack (data->sock, tftph->u.data.block);
if (err)
return err;