bc092b9
From 27f7b88ae111b6b0e32fc97b1e4584ba110497c3 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
bc092b9
Subject: [PATCH 063/176] 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
bc092b9
index 54306e3b1..d1c69ed2b 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
+          {
f4c76c0
+            grub_dprintf ("net", "arp packet with abnormal size (%ld 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
-- 
bc092b9
2.13.0
f4c76c0