]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* grub-core/kern/ieee1275/openfw.c (grub_devalias_iterate): Fix
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sat, 24 Dec 2011 01:45:17 +0000 (02:45 +0100)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sat, 24 Dec 2011 01:45:17 +0000 (02:45 +0100)
allocation and zero-setting.
(grub_ieee1275_get_devname): Check that alias is complete.

ChangeLog
grub-core/kern/ieee1275/openfw.c

index 18f6778c5ecd59a3586936ae34bf6f1066bbd549..f62a3a11bd3c9e1a706960c207a51c9366bc6bb2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
index a063cfe63378b7651e179c1965546a995aac01c2..2c081e57d376db47fd0df400b435cd356bd5663c 100644 (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;