From 6a4737e5d8fb4d8a81e5b432bfa0196f30f35c97 Mon Sep 17 00:00:00 2001 From: davem Date: Mon, 13 Apr 2009 23:01:54 +0000 Subject: [PATCH] * util/hostdisk.c (make_device_name): Do not make any assumptions about the length of drive names. --- ChangeLog | 3 +++ util/hostdisk.c | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index a0d5fdfe2..9a05c38f8 100644 --- 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 * kern/misc.c (grub_ltoa): Fix cast when handling negative diff --git a/util/hostdisk.c b/util/hostdisk.c index 2ef205786..fd01a263b 100644 --- a/util/hostdisk.c +++ b/util/hostdisk.c @@ -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)