This is the mail archive of the binutils-cvs@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] More fixes for bfd_get_section_contents change


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=7211ae501eb0de1044983f2dfb00091a58fbd66c

commit 7211ae501eb0de1044983f2dfb00091a58fbd66c
Author: Alan Modra <amodra@gmail.com>
Date:   Tue Jun 27 09:45:04 2017 +0930

    More fixes for bfd_get_section_contents change
    
    	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".

Diff:
---
 bfd/ChangeLog |  8 ++++++++
 bfd/libbfd.c  | 18 ++++--------------
 2 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index c2491d5..f440f8f 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -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
diff --git a/bfd/libbfd.c b/bfd/libbfd.c
index b8c65b5..0776451 100644
--- a/bfd/libbfd.c
+++ b/bfd/libbfd.c
@@ -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;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]