From 7df0da33f4789e264242a4cb8af30c0aefe6d6b4 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Mon, 17 Nov 2014 23:01:34 +0100 Subject: [PATCH] readelf: Warn if ptr_size is not 4 or 8 bytes. Just warn and don't call print_cfa_program in that case. Bad things will happen and the result is mostly bogus. Signed-off-by: Mark Wielaard --- src/ChangeLog | 5 +++++ src/readelf.c | 9 ++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 737c674..96f21fd 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2014-11-17 Mark Wielaard + + * readelf.c (print_debug_frame_section): Warn if ptr_size is not 4 + or 8 instead of just calling print_cfa_program. + 2014-11-16 Mark Wielaard * readelf (process_elf_file): Set phnum to zero if there aren't diff --git a/src/readelf.c b/src/readelf.c index 583b5da..bd97ca6 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -5626,9 +5626,12 @@ print_debug_frame_section (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr, } /* Handle the initialization instructions. */ - print_cfa_program (readp, cieend, vma_base, code_alignment_factor, - data_alignment_factor, version, ptr_size, - dwflmod, ebl, dbg); + if (ptr_size != 4 && ptr_size !=8) + printf ("invalid CIE pointer size (%u), must be 4 or 8.\n", ptr_size); + else + print_cfa_program (readp, cieend, vma_base, code_alignment_factor, + data_alignment_factor, version, ptr_size, + dwflmod, ebl, dbg); readp = cieend; } } -- 2.7.4