PR27860, Segmentation fault on readelf -w

Message ID 20210513132204.GV25246@bubble.grove.modra.org
State New
Headers show
Series
  • PR27860, Segmentation fault on readelf -w
Related show

Commit Message

H.J. Lu via Binutils May 13, 2021, 1:22 p.m.
Well it didn't take long for the SAFE_BYTE_GET assert to trigger.

	PR 27860
	* dwarf.c (display_debug_frames): Sanity check cie_off before
	attempting to read cie.


-- 
Alan Modra
Australia Development Lab, IBM

Patch

diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index 56983e1c799..20bd92657b3 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -8708,6 +8708,8 @@  display_debug_frames (struct dwarf_section *section,
 		if (cie->chunk_start == look_for)
 		  break;
 	    }
+	  else if (cie_off >= section->size)
+	    cie = NULL;
 	  else
 	    {
 	      for (cie = forward_refs; cie ; cie = cie->next)