[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH]: grub: Kill fixed device name length from make_device_name().
From: |
David Miller |
Subject: |
[PATCH]: grub: Kill fixed device name length from make_device_name(). |
Date: |
Sun, 12 Apr 2009 23:53:04 -0700 (PDT) |
make_device_name() uses an arbitrary value for the device name
length, putting an arbitrary limit on such strings.
We can do better by calculating the length of this string precisely.
2009-04-12 David S. Miller <address@hidden>
* util/hostdisk.c (make_device_name): Do not make any assumptions
about the length of drive names.
---
util/hostdisk.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/util/hostdisk.c b/util/hostdisk.c
index 2ef2057..fd01a26 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)
--
1.6.2.3
- [PATCH]: grub: Kill fixed device name length from make_device_name().,
David Miller <=