37b39b7
From cf2e819b7059f199075b099260983e8108eea74a Mon Sep 17 00:00:00 2001
37b39b7
From: Paulo Flabiano Smorigo <pfsmorigo@br.ibm.com>
37b39b7
Date: Wed, 5 Feb 2014 09:42:42 -0200
58fe9aa
Subject: [PATCH 133/152] trim arp packets with abnormal size
37b39b7
37b39b7
GRUB uses arp request to create the arp response. If the incoming packet
37b39b7
is foobared, GRUB needs to trim the arp response packet before sending it.
37b39b7
---
37b39b7
 grub-core/net/arp.c | 6 ++++++
37b39b7
 1 file changed, 6 insertions(+)
37b39b7
37b39b7
diff --git a/grub-core/net/arp.c b/grub-core/net/arp.c
37b39b7
index d62d0cc..77581f4 100644
37b39b7
--- a/grub-core/net/arp.c
37b39b7
+++ b/grub-core/net/arp.c
37b39b7
@@ -162,6 +162,12 @@ grub_net_arp_receive (struct grub_net_buff *nb,
37b39b7
     if (grub_net_addr_cmp (&inf->address, &target_addr) == 0
37b39b7
 	&& grub_be_to_cpu16 (arp_header->op) == ARP_REQUEST)
37b39b7
       {
37b39b7
+        if ((nb->tail - nb->data) > 50)
37b39b7
+          {
37b39b7
+            grub_dprintf ("net", "arp packet with abnormal size (%ld bytes).\n",
37b39b7
+                         nb->tail - nb->data);
37b39b7
+            nb->tail = nb->data + 50;
37b39b7
+          }
37b39b7
 	grub_net_link_level_address_t target;
37b39b7
 	/* We've already checked that pln is either 4 or 16.  */
37b39b7
 	char tmp[16];
37b39b7
-- 
37b39b7
1.9.3
37b39b7