This is the mail archive of the binutils@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]

[committed]: Fix think in cast (archive.c)


Hi,

when binutils is built with a 32 bit compiler on Darwin, archive files are not recognized.  This is due to a thinko in a cast:
 (file_ptr) -(sizeof (hdr) + 20)
as size_t is an unsigned 32 bit integer and file_ptr a 64 bit integer, this results in a large 32 bit number, and following read will
fail.
This code was only executed for Darwin archives.

Fixed, manually tested and committed as obvious.

Tristan.

2012-02-02  Tristan Gingold  <gingold@adacore.com>

	* archive.c (bfd_slurp_armap): Fix thinko in cast.

diff --git a/bfd/archive.c b/bfd/archive.c
index 86c62a5..fd44f54 100644
--- a/bfd/archive.c
+++ b/bfd/archive.c
@@ -1103,7 +1103,7 @@ bfd_slurp_armap (bfd *abfd)
       /* Read the extended name.  We know its length.  */
       if (bfd_bread (extname, 20, abfd) != 20)
         return FALSE;
-      if (bfd_seek (abfd, (file_ptr) -(sizeof (hdr) + 20), SEEK_CUR) != 0)
+      if (bfd_seek (abfd, -(file_ptr) (sizeof (hdr) + 20), SEEK_CUR) != 0)
         return FALSE;
       if (CONST_STRNEQ (extname, "__.SYMDEF SORTED")
           || CONST_STRNEQ (extname, "__.SYMDEF"))


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