PR24235, Read memory violation in pei-x86_64.c
authorAlan Modra <amodra@gmail.com>
Tue, 19 Feb 2019 12:18:44 +0000 (22:48 +1030)
committerAlan Modra <amodra@gmail.com>
Tue, 19 Feb 2019 12:22:55 +0000 (22:52 +1030)
PR 24235
* pei-x86_64.c (pex64_bfd_print_pdata_section): Correct checks
attempting to prevent read past end of section.

bfd/ChangeLog
bfd/pei-x86_64.c

index d173adcc7cf37fbafdf11b2269e9405b77fceb21..72c87c78a29a4d5fb4dc4ee6f78e1c3b1b0c6f42 100644 (file)
@@ -1,3 +1,9 @@
+2019-02-19  Alan Modra  <amodra@gmail.com>
+
+       PR 24235
+       * pei-x86_64.c (pex64_bfd_print_pdata_section): Correct checks
+       attempting to prevent read past end of section.
+
 2019-02-18  Alan Modra  <amodra@gmail.com>
 
        PR 24225
index ff1093c1e3e6be4f83a6be4e5c7648e7d9e10ecc..7e751049f73dec8eb5f76343683c0fe4db865cfb 100644 (file)
@@ -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]);
This page took 0.02732 seconds and 4 git commands to generate.