Revision: 2106
http://svn.sv.gnu.org/viewvc/?view=rev&root=grub&revision=2106
Author: davem
Date: 2009-04-14 09:07:25 +0000 (Tue, 14 Apr 2009)
Log Message:
-----------
* util/hostdisk.c (make_device_name): Fix buffer length
calculations.
Modified Paths:
--------------
trunk/grub2/ChangeLog
trunk/grub2/util/hostdisk.c
Modified: trunk/grub2/ChangeLog
===================================================================
--- trunk/grub2/ChangeLog 2009-04-14 07:01:34 UTC (rev 2105)
+++ trunk/grub2/ChangeLog 2009-04-14 09:07:25 UTC (rev 2106)
@@ -1,3 +1,9 @@
+2009-04-14 John Stanley <[email protected]>
+ David S. Miller <[email protected]>
+
+ * util/hostdisk.c (make_device_name): Fix buffer length
+ calculations.
+
2009-04-14 Felix Zielcke <[email protected]>
* util/hostdisk.c [__FreeBSD__ || __FreeBSD_kernel__]: Include
Modified: trunk/grub2/util/hostdisk.c
===================================================================
--- trunk/grub2/util/hostdisk.c 2009-04-14 07:01:34 UTC (rev 2105)
+++ trunk/grub2/util/hostdisk.c 2009-04-14 09:07:25 UTC (rev 2106)
@@ -656,11 +656,21 @@
char *p;
if (dos_part >= 0)
- len += 1 + ((dos_part + 1) / 10);
+ {
+ /* Add in char length of dos_part+1 */
+ int tmp = dos_part + 1;
+ len++;
+ while ((tmp /= 10) != 0)
+ len++;
+ }
if (bsd_part >= 0)
len += 2;
- p = xmalloc (len);
+ /* Length to alloc is: char length of map[drive].drive, plus
+ * char length of (dos_part+1) or of bsd_part, plus
+ * 2 for the comma and a null/end of string (\0)
+ */
+ p = xmalloc (len + 2);
sprintf (p, "%s", map[drive].drive);
if (dos_part >= 0)