Blame SOURCES/0482-Fix-net_bootp-cmd-crash-when-there-isn-t-network-car.patch

f96e0b
From 0475cf691e25ffe50756690d7199d425e200307c Mon Sep 17 00:00:00 2001
f96e0b
From: Paulo Flabiano Smorigo <pfsmorigo@br.ibm.com>
f96e0b
Date: Mon, 6 May 2013 12:32:33 -0300
f96e0b
Subject: [PATCH 482/482] Fix net_bootp cmd crash when there isn't network card
f96e0b
f96e0b
Adds a check for a network card available before trying to procedure with bootp.
f96e0b
f96e0b
This fixes the bugzilla bellow:
f96e0b
Bug 960624 - Grub2 crashes when net_bootp command fails
f96e0b
https://bugzilla.redhat.com/show_bug.cgi?id=960624
f96e0b
---
f96e0b
 grub-core/net/bootp.c | 6 ++++++
f96e0b
 include/grub/err.h    | 1 +
f96e0b
 2 files changed, 7 insertions(+)
f96e0b
f96e0b
diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c
f96e0b
index af3cb62..26e3be4 100644
f96e0b
--- a/grub-core/net/bootp.c
f96e0b
+++ b/grub-core/net/bootp.c
f96e0b
@@ -483,6 +483,12 @@ grub_cmd_bootp (struct grub_command *cmd __attribute__ ((unused)),
f96e0b
     ncards++;
f96e0b
   }
f96e0b
 
f96e0b
+  if (ncards == 0)
f96e0b
+    {
f96e0b
+      err = grub_error (GRUB_ERR_NET_NO_CARD, N_("no network card found"));
f96e0b
+      return err;
f96e0b
+    }
f96e0b
+
f96e0b
   ifaces = grub_zalloc (ncards * sizeof (ifaces[0]));
f96e0b
   if (!ifaces)
f96e0b
     return grub_errno;
f96e0b
diff --git a/include/grub/err.h b/include/grub/err.h
f96e0b
index 0f9b208..9896fcc 100644
f96e0b
--- a/include/grub/err.h
f96e0b
+++ b/include/grub/err.h
f96e0b
@@ -62,6 +62,7 @@ typedef enum
f96e0b
     GRUB_ERR_NET_ROUTE_LOOP,
f96e0b
     GRUB_ERR_NET_NO_ROUTE,
f96e0b
     GRUB_ERR_NET_NO_ANSWER,
f96e0b
+    GRUB_ERR_NET_NO_CARD,
f96e0b
     GRUB_ERR_WAIT,
f96e0b
     GRUB_ERR_BUG,
f96e0b
     GRUB_ERR_NET_PORT_CLOSED,
f96e0b
-- 
f96e0b
1.8.2.1
f96e0b