[committed]: Fix think in cast (archive.c)
Tristan Gingold
gingold@adacore.com
Thu Feb 2 11:35:00 GMT 2012
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"))
More information about the Binutils
mailing list