]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* util/hostdisk.c (make_device_name): Do not make any assumptions
authordavem <davem@localhost>
Mon, 13 Apr 2009 23:01:54 +0000 (23:01 +0000)
committerdavem <davem@localhost>
Mon, 13 Apr 2009 23:01:54 +0000 (23:01 +0000)
about the length of drive names.

ChangeLog
util/hostdisk.c

index a0d5fdfe211f3fcb7b703617a598f90e71ee850f..9a05c38f81a945b6048e443e285f1b0b3fb8167c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -46,6 +46,9 @@
        * conf/common.rmk (grub_probe_SOURCES): Add Sun partition module.
        (grub_fstest_SOURCES): Likewise.
 
+       * util/hostdisk.c (make_device_name): Do not make any assumptions
+       about the length of drive names.
+
 2009-04-12  David S. Miller  <davem@davemloft.net>
 
        * kern/misc.c (grub_ltoa): Fix cast when handling negative
index 2ef2057860e8b14ebd1b9b5c429d85b37ca55e62..fd01a263b355f9cd33b5a1b173d72bb7115615f9 100644 (file)
@@ -622,9 +622,15 @@ grub_util_biosdisk_fini (void)
 static char *
 make_device_name (int drive, int dos_part, int bsd_part)
 {
+  int len = strlen(map[drive].drive);
   char *p;
 
-  p = xmalloc (30);
+  if (dos_part >= 0)
+    len += 1 + ((dos_part + 1) / 10);
+  if (bsd_part >= 0)
+    len += 2;
+
+  p = xmalloc (len);
   sprintf (p, "%s", map[drive].drive);
   
   if (dos_part >= 0)