diff options
author | Gary Benson <gbenson@redhat.com> | 2018-10-09 14:13:12 +0100 |
---|---|---|
committer | Gary Benson <gbenson@redhat.com> | 2018-10-09 14:13:12 +0100 |
commit | 04fd5eed91c0a960e1706fb627912ad6350ae391 (patch) | |
tree | fa22e7c3085d31fca32e1b76663aa58ecc9a9a09 | |
parent | 1c2649ed7481881cb963bb53251a79bfb8b1047e (diff) | |
download | gdb-04fd5eed91c0a960e1706fb627912ad6350ae391.zip gdb-04fd5eed91c0a960e1706fb627912ad6350ae391.tar.gz gdb-04fd5eed91c0a960e1706fb627912ad6350ae391.tar.bz2 |
Fix buffer overrun found by Coverity
This commit fixes a buffer overrun found by Coverity, where
36 bytes are written into a 24 byte buffer.
gdb/ChangeLog:
* dwarf2read.c (create_dwp_hash_table): Fix buffer overrun
found by Coverity.
-rw-r--r-- | gdb/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/dwarf2read.c | 5 |
2 files changed, 8 insertions, 2 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index e8deee8..f37070e 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2018-10-09 Gary Benson <gbenson@redhat.com> + + * dwarf2read.c (create_dwp_hash_table): Fix buffer overrun + found by Coverity. + 2018-10-08 Tom Tromey <tom@tromey.com> * riscv-fbsd-tdep.c (riscv_fbsd_sigframe_init): Remove unused diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index c952996..2a1b805 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -12196,6 +12196,7 @@ create_dwp_hash_table (struct dwarf2_per_objfile *dwarf2_per_objfile, { const gdb_byte *ids_ptr = htab->unit_table + sizeof (uint32_t) * nr_slots; int *ids = htab->section_pool.v2.section_ids; + size_t sizeof_ids = sizeof (htab->section_pool.v2.section_ids); /* Reverse map for error checking. */ int ids_seen[DW_SECT_MAX + 1]; int i; @@ -12212,8 +12213,8 @@ create_dwp_hash_table (struct dwarf2_per_objfile *dwarf2_per_objfile, " in section table [in module %s]"), dwp_file->name); } - memset (ids, 255, (DW_SECT_MAX + 1) * sizeof (int32_t)); - memset (ids_seen, 255, (DW_SECT_MAX + 1) * sizeof (int32_t)); + memset (ids, 255, sizeof_ids); + memset (ids_seen, 255, sizeof (ids_seen)); for (i = 0; i < nr_columns; ++i) { int id = read_4_bytes (dbfd, ids_ptr + i * sizeof (uint32_t)); |