From d1dff95dc7fa3c5227b038ce44e482000ecbf8fe Mon Sep 17 00:00:00 2001 From: proski Date: Fri, 30 May 2008 03:57:16 +0000 Subject: [PATCH] 2008-05-29 Pavel Roskin * disk/lvm.c (grub_lvm_scan_device): Check for the buffer end when scanning metadata for volume group name. --- ChangeLog | 3 +++ disk/lvm.c | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 90536390c..eec4edcd1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2008-05-29 Pavel Roskin + * disk/lvm.c (grub_lvm_scan_device): Check for the buffer end + when scanning metadata for volume group name. + * include/grub/script.h: Don't include grub_script.tab.h. It's a generated file, which may only be included from the files with DEPENDENCIES rules in the makefile. Don't use typedef YYSTYPE, diff --git a/disk/lvm.c b/disk/lvm.c index 1d898ff55..997d15cd5 100644 --- a/disk/lvm.c +++ b/disk/lvm.c @@ -302,9 +302,12 @@ grub_lvm_scan_device (const char *name) rlocn = mdah->raw_locns; p = q = metadatabuf + grub_le_to_cpu64 (rlocn->offset); - while (*q != ' ') + while (*q != ' ' && q < metadatabuf + mda_size) q++; + if (q == metadatabuf + mda_size) + goto fail2; + vgname_len = q - p; vgname = grub_malloc (vgname_len + 1); if (!vgname)