[2102] * util/hostdisk.c (make_device_name): Do not make any assumptions

"David S. Miller" <[email protected]>
Newsgroups gmane.comp.boot-loaders.grub.cvs
Message-ID <[email protected]>
Revision: 2102
          http://svn.sv.gnu.org/viewvc/?view=rev&root=grub&revision=2102
Author:   davem
Date:     2009-04-13 23:01:54 +0000 (Mon, 13 Apr 2009)
Log Message:
-----------
	* util/hostdisk.c (make_device_name): Do not make any assumptions
	about the length of drive names.

Modified Paths:
--------------
    trunk/grub2/ChangeLog
    trunk/grub2/util/hostdisk.c

Modified: trunk/grub2/ChangeLog
===================================================================
--- trunk/grub2/ChangeLog	2009-04-13 20:35:59 UTC (rev 2101)
+++ trunk/grub2/ChangeLog	2009-04-13 23:01:54 UTC (rev 2102)
@@ -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  <[email protected]>
 
 	* kern/misc.c (grub_ltoa): Fix cast when handling negative

Modified: trunk/grub2/util/hostdisk.c
===================================================================
--- trunk/grub2/util/hostdisk.c	2009-04-13 20:35:59 UTC (rev 2101)
+++ trunk/grub2/util/hostdisk.c	2009-04-13 23:01:54 UTC (rev 2102)
@@ -622,9 +622,15 @@
 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)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.