From 9e4d19e0d362613b566d824cc609b875c630e2b1 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 29 Mar 2011 15:00:23 +0200 Subject: [PATCH] * grub-core/kern/emu/hostdisk.c (find_partition_start) [HAVE_DIOCGDINFO]: Add safety checks. --- ChangeLog | 5 +++++ grub-core/kern/emu/hostdisk.c | 9 ++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8b593f634..a7ed9fc94 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-03-29 Vladimir Serbinenko + + * grub-core/kern/emu/hostdisk.c (find_partition_start) + [HAVE_DIOCGDINFO]: Add safety checks. + 2011-03-29 Vladimir Serbinenko * util/grub.d/10_kfreebsd.in: Allow ufs.ko to be missing as it's diff --git a/grub-core/kern/emu/hostdisk.c b/grub-core/kern/emu/hostdisk.c index 73d023ce9..9900a79bd 100644 --- a/grub-core/kern/emu/hostdisk.c +++ b/grub-core/kern/emu/hostdisk.c @@ -518,9 +518,12 @@ devmapper_fail: # if !defined(HAVE_DIOCGDINFO) return hdg.start; # else /* defined(HAVE_DIOCGDINFO) */ - p_index = dev[strlen(dev) - 1] - 'a'; - - if (p_index >= label.d_npartitions) + if (dev[0]) + p_index = dev[strlen(dev) - 1] - 'a'; + else + p_index = -1; + + if (p_index >= label.d_npartitions || p_index < 0) { grub_error (GRUB_ERR_BAD_DEVICE, "no disk label entry for `%s'", dev);