This is the mail archive of the
mailing list for the binutils project.
[committed]: Fix think in cast (archive.c)
- From: Tristan Gingold <gingold at adacore dot com>
- To: binutils Development <binutils at sourceware dot org>
- Date: Thu, 2 Feb 2012 12:35:17 +0100
- Subject: [committed]: Fix think in cast (archive.c)
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
This code was only executed for Darwin archives.
Fixed, manually tested and committed as obvious.
2012-02-02 Tristan Gingold <email@example.com>
* archive.c (bfd_slurp_armap): Fix thinko in cast.
diff --git a/bfd/archive.c b/bfd/archive.c
index 86c62a5..fd44f54 100644
@@ -1103,7 +1103,7 @@ bfd_slurp_armap (bfd *abfd)
/* Read the extended name. We know its length. */
if (bfd_bread (extname, 20, abfd) != 20)
- if (bfd_seek (abfd, (file_ptr) -(sizeof (hdr) + 20), SEEK_CUR) != 0)
+ if (bfd_seek (abfd, -(file_ptr) (sizeof (hdr) + 20), SEEK_CUR) != 0)
if (CONST_STRNEQ (extname, "__.SYMDEF SORTED")
|| CONST_STRNEQ (extname, "__.SYMDEF"))