Skip to content

Commit 179f2db

Browse files
committed
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.
1 parent c72e75a commit 179f2db

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

bfd/ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
2019-02-19 Alan Modra <[email protected]>
2+
3+
PR 24235
4+
* pei-x86_64.c (pex64_bfd_print_pdata_section): Correct checks
5+
attempting to prevent read past end of section.
6+
17
2019-02-18 Alan Modra <[email protected]>
28

39
PR 24225

bfd/pei-x86_64.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ pex64_bfd_print_pdata_section (bfd *abfd, void *vfile, asection *pdata_section)
541541
/* virt_size might be zero for objects. */
542542
if (stop == 0 && strcmp (abfd->xvec->name, "pe-x86-64") == 0)
543543
{
544-
stop = (datasize / onaline) * onaline;
544+
stop = datasize;
545545
virt_size_is_zero = TRUE;
546546
}
547547
else if (datasize < stop)
@@ -551,8 +551,8 @@ pex64_bfd_print_pdata_section (bfd *abfd, void *vfile, asection *pdata_section)
551551
_("Warning: %s section size (%ld) is smaller than virtual size (%ld)\n"),
552552
pdata_section->name, (unsigned long) datasize,
553553
(unsigned long) stop);
554-
/* Be sure not to read passed datasize. */
555-
stop = datasize / onaline;
554+
/* Be sure not to read past datasize. */
555+
stop = datasize;
556556
}
557557

558558
/* Display functions table. */
@@ -724,8 +724,7 @@ pex64_bfd_print_pdata_section (bfd *abfd, void *vfile, asection *pdata_section)
724724
altent += imagebase;
725725

726726
if (altent >= pdata_vma
727-
&& (altent + PDATA_ROW_SIZE <= pdata_vma
728-
+ pei_section_data (abfd, pdata_section)->virt_size))
727+
&& altent - pdata_vma + PDATA_ROW_SIZE <= stop)
729728
{
730729
pex64_get_runtime_function
731730
(abfd, &arf, &pdata[altent - pdata_vma]);

0 commit comments

Comments
 (0)