]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Properly check indicies bigger than 4Gb
authorH.J. Lu <hjl.tools@gmail.com>
Sun, 9 Dec 2012 18:06:44 +0000 (18:06 +0000)
committerH.J. Lu <hjl.tools@gmail.com>
Sun, 9 Dec 2012 18:06:44 +0000 (18:06 +0000)
PR binutils/14933
* archive.c (bsd_write_armap): Properly check indicies bigger than
4Gb.

bfd/ChangeLog
bfd/archive.c

index 28b27d30f0d0547f498e3f2f8761a4b2ee5b59cb..235a7538bd3b89fd0f0b7895f5a141d4e2dbbf97 100644 (file)
@@ -1,3 +1,9 @@
+2012-12-09  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR binutils/14933
+       * archive.c (bsd_write_armap): Properly check indicies bigger than
+       4Gb.
+
 2012-11-29  Roland McGrath  <mcgrathr@google.com>
 
        * elf-nacl.c (segment_eligible_for_headers): Disallow writable segments.
index fe57755770bbbfc43be705fb5c437dd8619dff7d..5814b4609767fc758610a9b29d411786b5bf9bf1 100644 (file)
@@ -2408,9 +2408,6 @@ bsd_write_armap (bfd *arch,
   unsigned int count;
   struct ar_hdr hdr;
   long uid, gid;
-  file_ptr max_first_real = 1;
-
-  max_first_real <<= 31;
 
   firstreal = mapsize + elength + sizeof (struct ar_hdr) + SARMAG;
 
@@ -2453,6 +2450,7 @@ bsd_write_armap (bfd *arch,
 
   for (count = 0; count < orl_count; count++)
     {
+      unsigned int offset;
       bfd_byte buf[BSD_SYMDEF_SIZE];
 
       if (map[count].u.abfd != last_elt)
@@ -2472,7 +2470,8 @@ bsd_write_armap (bfd *arch,
       /* The archive file format only has 4 bytes to store the offset
         of the member.  Check to make sure that firstreal has not grown
         too big.  */
-      if (firstreal >= max_first_real)
+      offset = (unsigned int) firstreal;
+      if (firstreal != (file_ptr) offset)
        {
          bfd_set_error (bfd_error_file_truncated);
          return FALSE;