2008-10-05 Hans Lambermont <hans@lambermont.dyndns.org>
* disk/lvm.c (grub_lvm_scan_device): Allocate buffer space for the circular metadata worst case scenario. If the metadata is circular then copy the wrap in place. * include/grub/lvm.h: Add GRUB_LVM_MDA_HEADER_SIZE, from the LVM2 project lib/format_text/layout.h Circular metadata bug found and patch debugged by Jan Derk Gerlings.
This commit is contained in:
parent
7a36edcafd
commit
1b7748eb13
3 changed files with 22 additions and 1 deletions
13
disk/lvm.c
13
disk/lvm.c
|
@ -281,7 +281,8 @@ grub_lvm_scan_device (const char *name)
|
|||
goto fail;
|
||||
}
|
||||
|
||||
metadatabuf = grub_malloc (mda_size);
|
||||
/* Allocate buffer space for the circular worst-case scenario. */
|
||||
metadatabuf = grub_malloc (2 * mda_size);
|
||||
if (! metadatabuf)
|
||||
goto fail;
|
||||
|
||||
|
@ -300,6 +301,16 @@ grub_lvm_scan_device (const char *name)
|
|||
}
|
||||
|
||||
rlocn = mdah->raw_locns;
|
||||
if (grub_le_to_cpu64 (rlocn->offset) + grub_le_to_cpu64 (rlocn->size) >
|
||||
grub_le_to_cpu64 (mdah->size))
|
||||
{
|
||||
/* Metadata is circular. Copy the wrap in place. */
|
||||
grub_memcpy (metadatabuf + mda_size,
|
||||
metadatabuf + GRUB_LVM_MDA_HEADER_SIZE,
|
||||
grub_le_to_cpu64 (rlocn->offset) +
|
||||
grub_le_to_cpu64 (rlocn->size) -
|
||||
grub_le_to_cpu64 (mdah->size));
|
||||
}
|
||||
p = q = metadatabuf + grub_le_to_cpu64 (rlocn->offset);
|
||||
|
||||
while (*q != ' ' && q < metadatabuf + mda_size)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue