* [PATCH] Use dynamic allocation for the bootpath buffer
@ 2012-09-14 15:38 Paulo Flabiano Smorigo/Brazil/IBM
2012-12-10 15:23 ` Vladimir 'φ-coder/phcoder' Serbinenko
0 siblings, 1 reply; 2+ messages in thread
From: Paulo Flabiano Smorigo/Brazil/IBM @ 2012-09-14 15:38 UTC (permalink / raw)
To: grub-devel
[-- Attachment #1: Type: text/plain, Size: 242 bytes --]
Hi all,
There are some cases when the device path is bigger then 64 chars.
Using a dynamic allocation will avoid problems with the size.
--
Paulo Flabiano Smorigo
Software Engineer
Linux Technology Center - IBM Systems & Technology Group
[-- Attachment #2: bootpath_size.path --]
[-- Type: application/octet-stream, Size: 1764 bytes --]
=== modified file 'ChangeLog'
--- ChangeLog 2012-09-14 10:23:36 +0000
+++ ChangeLog 2012-09-14 21:46:17 +0000
@@ -1,3 +1,8 @@
+2012-09-14 Paulo Flabiano Smorigo <pfsmorigo@br.ibm.com>
+
+ * grub-core/kern/ieee1275/init.c (grub_machine_get_bootlocation): Use
+ dynamic allocation for the bootpath buffer.
+
2012-09-14 Colin Watson <cjwatson@ubuntu.com>
* grub-core/term/terminfo.c: Only fix up powerpc key repeat on
=== modified file 'grub-core/kern/ieee1275/init.c'
--- grub-core/kern/ieee1275/init.c 2012-06-11 18:44:38 +0000
+++ grub-core/kern/ieee1275/init.c 2012-09-14 21:27:28 +0000
@@ -82,18 +82,28 @@
void
grub_machine_get_bootlocation (char **device, char **path)
{
- char bootpath[64]; /* XXX check length */
+ char *bootpath;
+ grub_ssize_t bootpath_size;
char *filename;
char *type;
-
- if (grub_ieee1275_get_property (grub_ieee1275_chosen, "bootpath", &bootpath,
- sizeof (bootpath), 0))
+
+ if (grub_ieee1275_get_property_length (grub_ieee1275_chosen, "bootpath",
+ &bootpath_size))
{
/* Should never happen. */
grub_printf ("/chosen/bootpath property missing!\n");
return;
}
+ bootpath = (char *) grub_malloc ((grub_size_t) bootpath_size);
+ if (! bootpath)
+ {
+ grub_printf ("Cannot allocate bootpath buffer.\n");
+ return;
+ }
+ grub_ieee1275_get_property (grub_ieee1275_chosen, "bootpath", bootpath,
+ (grub_size_t) bootpath_size, 0);
+
/* Transform an OF device path to a GRUB path. */
type = grub_ieee1275_get_device_type (bootpath);
@@ -132,6 +142,7 @@
*path = filename;
}
}
+ grub_free (bootpath);
}
/* Claim some available memory in the first /memory node. */
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Use dynamic allocation for the bootpath buffer
2012-09-14 15:38 [PATCH] Use dynamic allocation for the bootpath buffer Paulo Flabiano Smorigo/Brazil/IBM
@ 2012-12-10 15:23 ` Vladimir 'φ-coder/phcoder' Serbinenko
0 siblings, 0 replies; 2+ messages in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2012-12-10 15:23 UTC (permalink / raw)
To: grub-devel
[-- Attachment #1: Type: text/plain, Size: 319 bytes --]
On 14.09.2012 17:38, Paulo Flabiano Smorigo/Brazil/IBM wrote:
> Hi all,
>
> There are some cases when the device path is bigger then 64 chars. Using
> a dynamic allocation will avoid problems with the size.
>
Applied after adding some precautions.
--
Regards
Vladimir 'φ-coder/phcoder' Serbinenko
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 294 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-12-10 15:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-14 15:38 [PATCH] Use dynamic allocation for the bootpath buffer Paulo Flabiano Smorigo/Brazil/IBM
2012-12-10 15:23 ` Vladimir 'φ-coder/phcoder' Serbinenko
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.