From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============2028688232633369328==" MIME-Version: 1.0 From: Mark Wielaard To: elfutils-devel@lists.fedorahosted.org Subject: [PATCH] readelf: Fix cie_offset calculation comparison on 32bit. Date: Wed, 22 Apr 2015 12:50:46 +0200 Message-ID: <1429699846-2117-1-git-send-email-mjw@redhat.com> --===============2028688232633369328== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable gcc -fsanitize=3Dundefined pointed out that on 32bit systems the calculation to match the cie_offset to the cie_id could be undefined because a cie_id could be an unsigned 64bit value while ptrdiff_t is only 32bits. Correct the calculation to use 64bit values. Signed-off-by: Mark Wielaard --- src/ChangeLog | 5 +++++ src/readelf.c | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 40a0e6f..6a1aa40 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,10 @@ 2015-03-22 Mark Wielaard = + * readelf.c (print_debug_frame_section): Cast start to Dwarf_Off + before subtracting cie_id. + +2015-03-22 Mark Wielaard + * readelf.c (print_gdb_index_section): Check all offsets used against section d_size. = diff --git a/src/readelf.c b/src/readelf.c index 26c7eed..550b00d 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -5619,8 +5619,8 @@ print_debug_frame_section (Dwfl_Module *dwflmod, Ebl = *ebl, GElf_Ehdr *ehdr, struct cieinfo *cie =3D cies; while (cie !=3D NULL) if (is_eh_frame - ? start - (ptrdiff_t) cie_id =3D=3D cie->cie_offset - : (ptrdiff_t) cie_id =3D=3D cie->cie_offset) + ? ((Dwarf_Off) start - cie_id) =3D=3D cie->cie_offset + : cie_id =3D=3D cie->cie_offset) break; else cie =3D cie->next; -- = 2.1.0 --===============2028688232633369328==--