aboutsummaryrefslogtreecommitdiff
path: root/bfd/pei-x86_64.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2019-02-19 22:48:44 +1030
committerAlan Modra <amodra@gmail.com>2019-02-19 22:52:55 +1030
commit179f2db0d9c397d7dd8a59907b84208b79f7f48c (patch)
treed5d6f959e97707dff173090be6f4d1ba43c9fbfe /bfd/pei-x86_64.c
parentc72e75a64030b0f6535a80481f37968ad55c333a (diff)
downloadgdb-179f2db0d9c397d7dd8a59907b84208b79f7f48c.zip
gdb-179f2db0d9c397d7dd8a59907b84208b79f7f48c.tar.gz
gdb-179f2db0d9c397d7dd8a59907b84208b79f7f48c.tar.bz2
PR24235, Read memory violation in pei-x86_64.c
PR 24235 * pei-x86_64.c (pex64_bfd_print_pdata_section): Correct checks attempting to prevent read past end of section.
Diffstat (limited to 'bfd/pei-x86_64.c')
-rw-r--r--bfd/pei-x86_64.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/bfd/pei-x86_64.c b/bfd/pei-x86_64.c
index ff1093c..7e75104 100644
--- a/bfd/pei-x86_64.c
+++ b/bfd/pei-x86_64.c
@@ -541,7 +541,7 @@ pex64_bfd_print_pdata_section (bfd *abfd, void *vfile, asection *pdata_section)
/* virt_size might be zero for objects. */
if (stop == 0 && strcmp (abfd->xvec->name, "pe-x86-64") == 0)
{
- stop = (datasize / onaline) * onaline;
+ stop = datasize;
virt_size_is_zero = TRUE;
}
else if (datasize < stop)
@@ -551,8 +551,8 @@ pex64_bfd_print_pdata_section (bfd *abfd, void *vfile, asection *pdata_section)
_("Warning: %s section size (%ld) is smaller than virtual size (%ld)\n"),
pdata_section->name, (unsigned long) datasize,
(unsigned long) stop);
- /* Be sure not to read passed datasize. */
- stop = datasize / onaline;
+ /* Be sure not to read past datasize. */
+ stop = datasize;
}
/* Display functions table. */
@@ -724,8 +724,7 @@ pex64_bfd_print_pdata_section (bfd *abfd, void *vfile, asection *pdata_section)
altent += imagebase;
if (altent >= pdata_vma
- && (altent + PDATA_ROW_SIZE <= pdata_vma
- + pei_section_data (abfd, pdata_section)->virt_size))
+ && altent - pdata_vma + PDATA_ROW_SIZE <= stop)
{
pex64_get_runtime_function
(abfd, &arf, &pdata[altent - pdata_vma]);