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

ranlib may break archives at random


If you're unlucky enough, the garbage following map[symbol_count-1]
may pass the test and we'd get one (or more) unexpected
archive_member_file_ptr, that causes the archive to become invalid.
It has happened to me for the past few weeks, while building
libstdc++-v3 on some old version of FreeBSD, and it has just happened
to me again on a different port.  Fixed thusly.  Ok to install?

Index: bfd/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	* archive.c (coff_write_armap): Don't write more than symbol_count
	`archive_member_file_ptr's.

Index: bfd/archive.c
===================================================================
RCS file: /cvs/src/src/bfd/archive.c,v
retrieving revision 1.12
diff -u -p -r1.12 archive.c
--- bfd/archive.c 2000/11/20 19:05:12 1.12
+++ bfd/archive.c 2000/12/25 20:53:51
@@ -2198,7 +2198,7 @@ coff_write_armap (arch, elength, map, sy
       /* For each symbol which is used defined in this object, write
 	 out the object file's address in the archive.  */
 
-      while (((bfd *) (map[count]).pos) == current)
+      while (count < symbol_count && ((bfd *) (map[count]).pos) == current)
 	{
 	  bfd_write_bigendian_4byte_int (arch, archive_member_file_ptr);
 	  count++;

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                  aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist    *Please* write to mailing lists, not to me

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