From 3e4b5bbeca8987527c11a1ea048459a7ebd4ab5e Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Wed, 16 Jun 2010 03:40:56 -0700 Subject: Add new dwarf_cfi_validate_fde call. --- libdw/fde.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'libdw/fde.c') diff --git a/libdw/fde.c b/libdw/fde.c index c826114c..5685252b 100644 --- a/libdw/fde.c +++ b/libdw/fde.c @@ -1,5 +1,5 @@ /* FDE reading. - Copyright (C) 2009 Red Hat, Inc. + Copyright (C) 2009-2010 Red Hat, Inc. This file is part of Red Hat elfutils. Red Hat elfutils is free software; you can redistribute it and/or modify @@ -139,8 +139,9 @@ intern_fde (Dwarf_CFI *cache, const Dwarf_FDE *entry) return fde; } -static struct dwarf_fde * -fde_by_offset (Dwarf_CFI *cache, Dwarf_Addr address, Dwarf_Off offset) +struct dwarf_fde * +internal_function +__libdw_fde_by_offset (Dwarf_CFI *cache, Dwarf_Off offset) { Dwarf_CFI_Entry entry; Dwarf_Off next_offset; @@ -167,10 +168,6 @@ fde_by_offset (Dwarf_CFI *cache, Dwarf_Addr address, Dwarf_Off offset) if (cache->next_offset == offset) cache->next_offset = next_offset; - /* Sanity check the address range. */ - if (address < fde->start || address >= fde->end) - goto invalid; - return fde; } @@ -254,7 +251,15 @@ __libdw_find_fde (Dwarf_CFI *cache, Dwarf_Addr address) Dwarf_Off offset = binary_search_fde (cache, address); if (offset == (Dwarf_Off) -1l) goto no_match; - return fde_by_offset (cache, address, offset); + struct dwarf_fde *fde = __libdw_fde_by_offset (cache, offset); + if (unlikely (fde != NULL) + /* Sanity check the address range. */ + && unlikely (address < fde->start || address >= fde->end)) + { + __libdw_seterrno (DWARF_E_INVALID_DWARF); + return NULL; + } + return fde; } /* It's not there. Read more CFI entries until we find it. */ -- cgit v1.2.3