]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
More fixes for bfd_get_section_contents change
authorAlan Modra <amodra@gmail.com>
Tue, 27 Jun 2017 00:15:04 +0000 (09:45 +0930)
committerAlan Modra <amodra@gmail.com>
Tue, 27 Jun 2017 00:16:45 +0000 (09:46 +0930)
PR binutils/21665
* libbfd.c (_bfd_generic_get_section_contents): Delete abort.
Use unsigned file pointer type, and remove cast.
* libbfd.c (_bfd_generic_get_section_contents_in_window): Likewise.
Add "count", not "sz".

bfd/ChangeLog
bfd/libbfd.c

index c2491d5233851ad054a98976e687a9e5c209327e..f440f8f57253176ea49751793c926454ab383f1b 100644 (file)
@@ -1,3 +1,11 @@
+2017-06-27  Alan Modra  <amodra@gmail.com>
+
+       PR binutils/21665
+       * libbfd.c (_bfd_generic_get_section_contents): Delete abort.
+       Use unsigned file pointer type, and remove cast.
+       * libbfd.c (_bfd_generic_get_section_contents_in_window): Likewise.
+       Add "count", not "sz".
+
 2017-06-26  Pedro Alves  <palves@redhat.com>
 
        PR binutils/21665
index b8c65b5e521cbe16b4b964d35031080cdd2d7666..077645119c09ab21c7d42f4f290a36f13e44c724 100644 (file)
@@ -789,7 +789,7 @@ _bfd_generic_get_section_contents (bfd *abfd,
                                   bfd_size_type count)
 {
   bfd_size_type sz;
-  file_ptr filesz;
+  ufile_ptr filesz;
   if (count == 0)
     return TRUE;
 
@@ -813,14 +813,9 @@ _bfd_generic_get_section_contents (bfd *abfd,
   else
     sz = section->size;
   filesz = bfd_get_file_size (abfd);
-  if (filesz < 0)
-    {
-      /* This should never happen.  */
-      abort ();
-    }
   if (offset + count < count
       || offset + count > sz
-      || (section->filepos + offset + count) > (bfd_size_type) filesz)
+      || section->filepos + offset + count > filesz)
     {
       bfd_set_error (bfd_error_invalid_operation);
       return FALSE;
@@ -843,7 +838,7 @@ _bfd_generic_get_section_contents_in_window
 {
 #ifdef USE_MMAP
   bfd_size_type sz;
-  file_ptr filesz;
+  ufile_ptr filesz;
 
   if (count == 0)
     return TRUE;
@@ -877,13 +872,8 @@ _bfd_generic_get_section_contents_in_window
   else
     sz = section->size;
   filesz = bfd_get_file_size (abfd);
-  if (filesz < 0)
-    {
-      /* This should never happen.  */
-      abort ();
-    }
   if (offset + count > sz
-      || (section->filepos + offset + sz) > (bfd_size_type) filesz
+      || section->filepos + offset + count > filesz
       || ! bfd_get_file_window (abfd, section->filepos + offset, count, w,
                                TRUE))
     return FALSE;