: grub: Kill fixed device name length from make_device_name().
PATCH 1/1 : grub: Kill fixed device name length from make_device_name().
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 <[email protected]>
* 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(-)
util/hostdisk.c +7 -1
@@ -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 )
Signature · 1 line
1.6.2.3
From: David Miller <[email protected]>
Date: Sun, 12 Apr 2009 23:53:04 -0700 (PDT)
Quoted 9 lines
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 <[email protected]>
*
util/hostdisk.c(make_device_name): Do not make any assumptions about the length of drive names.
This patch seems straightforward and no objections have been raised, so I've commited the change.