* [binutils-gdb] objdump buffer overflow in fetch_indexed_string
@ 2023-04-18 1:50 Alan Modra
0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2023-04-18 1:50 UTC (permalink / raw)
To: bfd-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=34d63622f677b577b927debb1d6fd2bfef4422bd
commit 34d63622f677b577b927debb1d6fd2bfef4422bd
Author: Alan Modra <amodra@gmail.com>
Date: Tue Apr 18 10:20:08 2023 +0930
objdump buffer overflow in fetch_indexed_string
PR 30361
* dwarf.c (fetch_indexed_string): Sanity check string index.
Diff:
---
binutils/dwarf.c | 20 +++++++-------------
1 file changed, 7 insertions(+), 13 deletions(-)
diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index 87ce1541d1c..86893c59dc7 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -659,14 +659,13 @@ fetch_indexed_string (uint64_t idx,
return (dwo ? _("<no .debug_str.dwo section>")
: _("<no .debug_str section>"));
- index_offset = idx * offset_size;
-
- if (this_set != NULL)
- index_offset += this_set->section_offsets [DW_SECT_STR_OFFSETS];
-
- index_offset += str_offsets_base;
-
- if (index_offset + offset_size > index_section->size)
+ if (_mul_overflow (idx, offset_size, &index_offset)
+ || (this_set != NULL
+ && ((index_offset += this_set->section_offsets [DW_SECT_STR_OFFSETS])
+ < this_set->section_offsets [DW_SECT_STR_OFFSETS]))
+ || (index_offset += str_offsets_base) < str_offsets_base
+ || index_offset + offset_size < offset_size
+ || index_offset + offset_size > index_section->size)
{
warn (_("string index of %" PRIu64 " converts to an offset of %#" PRIx64
" which is too big for section %s"),
@@ -675,11 +674,6 @@ fetch_indexed_string (uint64_t idx,
return _("<string index too big>");
}
- /* FIXME: If we are being paranoid then we should also check to see if
- IDX references an entry beyond the end of the string table pointed to
- by STR_OFFSETS_BASE. (Since there can be more than one string table
- in a DWARF string section). */
-
str_offset = byte_get (index_section->start + index_offset, offset_size);
str_offset -= str_section->address;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-04-18 1:50 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-18 1:50 [binutils-gdb] objdump buffer overflow in fetch_indexed_string Alan Modra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).