Skip to contentSkip to conversation

restrict parsing of `available'

PATCH In review Robert Millan 1 participant 2 messages Jan 13, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 restrict parsing of `available'

Another patch for i386-ieee1275. Again, I'd appreciate if someone can test it on PowerPC hardware.

Signature · 5 lines
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call, if you are unable to speak?
(as seen on /.)

* kern/powerpc/ieee1275/openfw.c (grub_available_iterate): Obtain actual size of `available' from grub_ieee1275_get_property(), and restrict parsing to that bound.

kern/powerpc/ieee1275/openfw.c +4 -2
diff -urp grub2/kern/powerpc/ieee1275/openfw.c grub2.available/kern/powerpc/ieee1275/openfw.c
@@ -141,6 +141,7 @@ grub_err_t grub_available_iterate (int (
   grub_ieee1275_phandle_t root;
   grub_ieee1275_phandle_t memory;
   grub_uint32_t available[32];
+  grub_size_t available_size;
   int address_cells = 1;
   int size_cells = 1;
   unsigned int i;
@@ -157,13 +158,14 @@ grub_err_t grub_available_iterate (int (
     return grub_error (GRUB_ERR_UNKNOWN_DEVICE,
 		       "Couldn't find /memory node");
   if (grub_ieee1275_get_property (memory, "available", available,
-				  sizeof available, 0))
+				  sizeof available, &available_size))
     return grub_error (GRUB_ERR_UNKNOWN_DEVICE,
 		       "Couldn't examine /memory/available property");
 
   /* Decode each entry and call `hook'.  */
   i = 0;
-  while (i < sizeof (available))
+  available_size /= sizeof (grub_uint32_t);
+  while (i < available_size)
     {
       grub_uint64_t address;
       grub_uint64_t size;
#1 lore raw
Quoted 1 line · Robert Millan

+ grub_size_t available_size;

Actually, this would be grub_ssize_t.

Signature · 5 lines
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call, if you are unable to speak?
(as seen on /.)