Index: util/getroot.c
===================================================================
--- util/getroot.c (Revision 1757)
+++ util/getroot.c (Arbeitskopie)
@@ -17,6 +17,7 @@
* along with GRUB. If not, see .
*/
+#define _GNU_SOURCE
#include
#include
#include
@@ -407,17 +408,16 @@
switch (grub_util_get_dev_abstraction (os_dev))
{
case GRUB_DEV_ABSTRACTION_LVM:
- grub_dev = xmalloc (strlen (os_dev) - 12 + 1);
- strcpy (grub_dev, os_dev + 12);
-
+ asprintf(&grub_dev,"%s",os_dev + strlen("/dev/mapper/") -1);
break;
case GRUB_DEV_ABSTRACTION_RAID:
- grub_dev = xmalloc (20);
if (os_dev[7] == '_' && os_dev[8] == 'd')
{
+ grub_dev = xmalloc (20);
+
const char *p;
/* This a partitionable RAID device of the form /dev/md_dNNpMM. */
@@ -457,9 +457,12 @@
}
else if (os_dev[7] >= '0' && os_dev[7] <= '9')
{
- memcpy (grub_dev, os_dev + 5, 7);
- grub_dev[7] = '\0';
+ asprintf(&grub_dev,"md%s",os_dev + sizeof("/dev/md") -1);
}
+ else if (os_dev[7] == '/' && os_dev[8] >= '0' && os_dev[8] <= '9')
+ {
+ asprintf(&grub_dev,"md%s",os_dev + sizeof("/dev/md/") -1);
+ }
else
grub_util_error ("Unknown kind of RAID device `%s'", os_dev);