6f1e3d5
From c0fa21c8898437747ce093884e6aba48d45ac329 Mon Sep 17 00:00:00 2001
f4c76c0
From: Paulo Flabiano Smorigo <pfsmorigo@br.ibm.com>
f4c76c0
Date: Wed, 5 Feb 2014 09:42:42 -0200
6f1e3d5
Subject: [PATCH 078/198] trim arp packets with abnormal size
f4c76c0
f4c76c0
GRUB uses arp request to create the arp response. If the incoming packet
f4c76c0
is foobared, GRUB needs to trim the arp response packet before sending it.
f4c76c0
---
f4c76c0
 grub-core/net/arp.c | 6 ++++++
f4c76c0
 1 file changed, 6 insertions(+)
f4c76c0
f4c76c0
diff --git a/grub-core/net/arp.c b/grub-core/net/arp.c
6f1e3d5
index 54306e3b1..2083b5a4b 100644
f4c76c0
--- a/grub-core/net/arp.c
f4c76c0
+++ b/grub-core/net/arp.c
bc092b9
@@ -150,6 +150,12 @@ grub_net_arp_receive (struct grub_net_buff *nb, struct grub_net_card *card,
f4c76c0
     if (grub_net_addr_cmp (&inf->address, &target_addr) == 0
f4c76c0
 	&& arp_packet->op == grub_cpu_to_be16_compile_time (ARP_REQUEST))
f4c76c0
       {
f4c76c0
+        if ((nb->tail - nb->data) > 50)
f4c76c0
+          {
6f1e3d5
+            grub_dprintf ("net", "arp packet with abnormal size (%d bytes).\n",
f4c76c0
+                         nb->tail - nb->data);
f4c76c0
+            nb->tail = nb->data + 50;
f4c76c0
+          }
f4c76c0
 	grub_net_link_level_address_t target;
f4c76c0
 	struct grub_net_buff nb_reply;
f4c76c0
 	struct arppkt *arp_reply;
f4c76c0
-- 
da63b36
2.14.3
f4c76c0