[12/19] display_debug_str_offsets

Message ID 20210515080957.20305-13-amodra@gmail.com
State New
Headers show
Series
  • Pointer UB in binutils/dwarf.c
Related show

Commit Message

Jan Beulich via Binutils May 15, 2021, 8:09 a.m.
* dwarf.c (display_debug_str_offsets): Constrain reads to length
	given in header.

Patch

diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index cd76f3f5e83..a0b84fc8d85 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -7480,12 +7480,12 @@  display_debug_str_offsets (struct dwarf_section *section,
 	    }
 
 	  int version;
-	  SAFE_BYTE_GET_AND_INC (version, curr, 2, end);
+	  SAFE_BYTE_GET_AND_INC (version, curr, 2, entries_end);
 	  if (version != 5)
 	    warn (_("Unexpected version number in str_offset header: %#x\n"), version);
 
 	  int padding;
-	  SAFE_BYTE_GET_AND_INC (padding, curr, 2, end);
+	  SAFE_BYTE_GET_AND_INC (padding, curr, 2, entries_end);
 	  if (padding != 0)
 	    warn (_("Unexpected value in str_offset header's padding field: %#x\n"), padding);