Blame SOURCES/0064-grub-core-kern-ieee1275-init.c-grub_machine_get_boot.patch

f96e0b
From 188fddf6f99533505a0f8c7c4f8223ba19d8ef6a Mon Sep 17 00:00:00 2001
f96e0b
From: Paulo Flabiano Smorigo <pfsmorigo@br.ibm.com>
f96e0b
Date: Mon, 10 Dec 2012 16:23:16 +0100
f96e0b
Subject: [PATCH 064/482] 	* grub-core/kern/ieee1275/init.c
f96e0b
 (grub_machine_get_bootlocation): Use 	dynamic allocation for the bootpath
f96e0b
 buffer.
f96e0b
f96e0b
---
f96e0b
 ChangeLog                      |  5 +++++
f96e0b
 grub-core/kern/ieee1275/init.c | 21 +++++++++++++++++----
f96e0b
 2 files changed, 22 insertions(+), 4 deletions(-)
f96e0b
f96e0b
diff --git a/ChangeLog b/ChangeLog
f96e0b
index ce822ee..8bd581e 100644
f96e0b
--- a/ChangeLog
f96e0b
+++ b/ChangeLog
f96e0b
@@ -1,3 +1,8 @@
f96e0b
+2012-12-10  Paulo Flabiano Smorigo <pfsmorigo@br.ibm.com>
f96e0b
+
f96e0b
+	* grub-core/kern/ieee1275/init.c (grub_machine_get_bootlocation): Use
f96e0b
+	dynamic allocation for the bootpath buffer.
f96e0b
+
f96e0b
 2012-12-10  Dr. Tilmann Bubeck <t.bubeck@reinform.de>
f96e0b
 
f96e0b
 	* grub-core/gfxmenu/view.c (init_terminal): Avoid making terminal
f96e0b
diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c
f96e0b
index 7d03a8a..14dcdf0 100644
f96e0b
--- a/grub-core/kern/ieee1275/init.c
f96e0b
+++ b/grub-core/kern/ieee1275/init.c
f96e0b
@@ -82,18 +82,30 @@ void (*grub_ieee1275_net_config) (const char *dev,
f96e0b
 void
f96e0b
 grub_machine_get_bootlocation (char **device, char **path)
f96e0b
 {
f96e0b
-  char bootpath[64]; /* XXX check length */
f96e0b
+  char *bootpath;
f96e0b
+  grub_ssize_t bootpath_size;
f96e0b
   char *filename;
f96e0b
   char *type;
f96e0b
-   
f96e0b
-  if (grub_ieee1275_get_property (grub_ieee1275_chosen, "bootpath", &bootpath,
f96e0b
-				  sizeof (bootpath), 0))
f96e0b
+
f96e0b
+  if (grub_ieee1275_get_property_length (grub_ieee1275_chosen, "bootpath",
f96e0b
+					 &bootpath_size)
f96e0b
+      || bootpath_size <= 0)
f96e0b
     {
f96e0b
       /* Should never happen.  */
f96e0b
       grub_printf ("/chosen/bootpath property missing!\n");
f96e0b
       return;
f96e0b
     }
f96e0b
 
f96e0b
+  bootpath = (char *) grub_malloc ((grub_size_t) bootpath_size + 64);
f96e0b
+  if (! bootpath)
f96e0b
+    {
f96e0b
+      grub_print_error ();
f96e0b
+      return;
f96e0b
+    }
f96e0b
+  grub_ieee1275_get_property (grub_ieee1275_chosen, "bootpath", bootpath,
f96e0b
+                              (grub_size_t) bootpath_size + 1, 0);
f96e0b
+  bootpath[bootpath_size] = '\0';
f96e0b
+
f96e0b
   /* Transform an OF device path to a GRUB path.  */
f96e0b
 
f96e0b
   type = grub_ieee1275_get_device_type (bootpath);
f96e0b
@@ -132,6 +144,7 @@ grub_machine_get_bootlocation (char **device, char **path)
f96e0b
 	  *path = filename;
f96e0b
 	}
f96e0b
     }
f96e0b
+  grub_free (bootpath);
f96e0b
 }
f96e0b
 
f96e0b
 /* Claim some available memory in the first /memory node. */
f96e0b
-- 
f96e0b
1.8.2.1
f96e0b