From 4e75f21c3321f1861bd78bb4d42c11ec0851d825 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 31 Mar 2012 12:27:10 +0200 Subject: [PATCH] * util/getroot.c (convert_system_partition_to_system_disk): Fix use after free. Reported by: Peter Jones. --- ChangeLog | 6 ++++++ util/getroot.c | 11 +++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index bda8fb46f..bdfa642ca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2012-03-31 Vladimir Serbinenko + + * util/getroot.c (convert_system_partition_to_system_disk): Fix use + after free. + Reported by: Peter Jones. + 2012-03-31 Anton Blanchard * grub-core/fs/iso9660.c (grub_iso9660_iterate_dir): Do not byteswap diff --git a/util/getroot.c b/util/getroot.c index be055bc32..c9415efce 100644 --- a/util/getroot.c +++ b/util/getroot.c @@ -1892,13 +1892,16 @@ devmapper_out: if (! mapper_name) grub_dprintf ("hostdisk", "%s has no DM name\n", path); } + char *ret; + if (mapper_name) + ret = xasprintf ("/dev/mapper/%s", mapper_name); + else + ret = NULL; + if (tree) dm_tree_free (tree); free (path); - if (mapper_name) - return xasprintf ("/dev/mapper/%s", mapper_name); - else - return NULL; + return ret; } #endif /* HAVE_DEVICE_MAPPER */ }