)]}'
{
  "commit": "6ec31a457e953f4dbcdb7740d6dda676cdfb2a73",
  "tree": "c02b14e35e183794948394ffe1c59896fd62351f",
  "parents": [
    "fdaf750f3271e45a2ca4b381e8e8d4058abbb58a"
  ],
  "author": {
    "name": "Tom de Vries",
    "email": "tdevries@suse.de",
    "time": "Fri May 02 22:21:36 2025 +0200"
  },
  "committer": {
    "name": "Tom de Vries",
    "email": "tdevries@suse.de",
    "time": "Fri May 02 22:21:36 2025 +0200"
  },
  "message": "[gdb/symtab] Throw DWARF error on out-of-bounds DW_FORM_strx\n\nWith the test-case contained in the patch, and gdb build with\n-fsanitize\u003daddress we get:\n...\n\u003d\u003d23678\u003d\u003dERROR: AddressSanitizer: heap-buffer-overflow ...^M\nREAD of size 1 at 0x6020000c30dc thread T3^[[1m^[[0m^M\nptype global_var^M\n    #0 0x2c6a40b in bfd_getl32 bfd/libbfd.c:846^M\n    #1 0x168f96c in read_str_index gdb/dwarf2/read.c:15349^M\n...\n\nThe executable contains an out-of-bounds DW_FORM_strx attribute:\n...\n$ readelf -wi $exec\n\u003c2eb\u003e   DW_AT_name        :readelf: Warning: string index of 1 converts to \\\n  an offset of 0xc which is too big for section .debug_str\n (indexed string: 0x1): \u003cstring index too big\u003e\n...\nand read_str_index doesn\u0027t check for this:\n...\n  info_ptr \u003d (str_offsets_section-\u003ebuffer\n\t      + str_offsets_base\n\t      + str_index * offset_size);\n   if (offset_size \u003d\u003d 4)\n     str_offset \u003d bfd_get_32 (abfd, info_ptr);\n...\nand consequently reads out-of-bounds.\n\nFix this in read_str_index by checking for the out-of-bounds condition and\nthrowing a DWARF error:\n...\n(gdb) ptype global_var\nDWARF Error: Offset from DW_FORM_GNU_str_index or DW_FORM_strx pointing \\\n  outside of .debug_str_offsets section in CU at offset 0x2d7 \\\n  [in module dw-form-strx-out-of-bounds]\nNo symbol \"global_var\" in current context.\n(gdb)\n...\n\nTested on x86_64-linux.\n\nApproved-By: Tom Tromey \u003ctom@tromey.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "951f9d26e4b419b5e775deda1185bc8b421e5428",
      "old_mode": 33188,
      "old_path": "gdb/dwarf2/read.c",
      "new_id": "6848f63aa2e4552b293a5cf7756a95af4e335c91",
      "new_mode": 33188,
      "new_path": "gdb/dwarf2/read.c"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "f2123fa7e079cd05dcb9f2596f84c3c39f04f455",
      "new_mode": 33188,
      "new_path": "gdb/testsuite/gdb.dwarf2/dw-form-strx-out-of-bounds.exp"
    }
  ]
}
