* grub-core/kern/ieee1275/openfw.c (grub_devalias_iterate): Fix

allocation and zero-setting.
	(grub_ieee1275_get_devname): Check that alias is complete.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2011-12-24 02:45:17 +01:00
parent 379586ad7d
commit ce4a999d4d
2 changed files with 14 additions and 4 deletions

View file

@ -1,3 +1,9 @@
2011-12-24 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/kern/ieee1275/openfw.c (grub_devalias_iterate): Fix
allocation and zero-setting.
(grub_ieee1275_get_devname): Check that alias is complete.
2011-12-24 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/kern/disk.c (grub_disk_read): Fix hook calling for

View file

@ -164,7 +164,7 @@ grub_devalias_iterate (int (*hook) (struct grub_ieee1275_devalias *alias))
strings, so we will add a NULL byte at the end explicitly. */
pathlen += 1;
devpath = grub_malloc (pathlen);
devpath = grub_malloc (pathlen + 1);
if (! devpath)
{
grub_free (devtype);
@ -173,12 +173,15 @@ grub_devalias_iterate (int (*hook) (struct grub_ieee1275_devalias *alias))
}
if (grub_ieee1275_get_property (aliases, aliasname, devpath, pathlen,
&actual))
&actual) || actual < 0)
{
grub_dprintf ("devalias", "get_property (%s) failed\n", aliasname);
goto nextprop;
}
devpath [actual] = '\0';
if (actual > pathlen)
actual = pathlen;
devpath[actual] = '\0';
devpath[pathlen] = '\0';
if (grub_ieee1275_finddevice (devpath, &dev))
{
@ -294,7 +297,8 @@ grub_ieee1275_get_devname (const char *path)
int match_alias (struct grub_ieee1275_devalias *curalias)
{
/* briQ firmware can change capitalization in /chosen/bootpath. */
if (! grub_strncasecmp (curalias->path, path, pathlen))
if (grub_strncasecmp (curalias->path, path, pathlen) == 0
&& curalias->path[pathlen] == 0)
{
newpath = grub_strdup (curalias->name);
return 1;