aboutsummaryrefslogtreecommitdiff
path: root/binutils/ar.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2013-02-15 14:37:39 +0000
committerNick Clifton <nickc@redhat.com>2013-02-15 14:37:39 +0000
commita043396b72d17ae87267b534aa98457a0702f5c8 (patch)
tree01175912495c045c25625c8048a83ba65c3a5c64 /binutils/ar.c
parent76d8cf45bb12ae6d8fc41d92579a2e166efb5b2f (diff)
downloadgdb-a043396b72d17ae87267b534aa98457a0702f5c8.zip
gdb-a043396b72d17ae87267b534aa98457a0702f5c8.tar.gz
gdb-a043396b72d17ae87267b534aa98457a0702f5c8.tar.bz2
PR binutils/15140
* ar.c (open_inarch): Fail on attempts to convert a normal archive to a thin archive or vice versa. * elfcomm.c (make_qualified_name): Handle corrupted thin archives. * readelf.c (process_archive): Likewise. * doc/binutils.texi: Clarify documentation describing thin archives. * archive.c (_bfd_get_elt_at_filepos): Prevent an infinite loop accessing a corrupt nested archive.
Diffstat (limited to 'binutils/ar.c')
-rw-r--r--binutils/ar.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/binutils/ar.c b/binutils/ar.c
index 0aa1ba3..c424038 100644
--- a/binutils/ar.c
+++ b/binutils/ar.c
@@ -1,7 +1,5 @@
/* ar.c - Archive modify and extract.
- Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
- 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013
- Free Software Foundation, Inc.
+ Copyright 1991-2013 Free Software Foundation, Inc.
This file is part of GNU Binutils.
@@ -918,6 +916,25 @@ open_inarch (const char *archive_filename, const char *file)
xexit (1);
}
+ if ((operation == replace || operation == quick_append)
+ && bfd_openr_next_archived_file (arch, NULL) != NULL)
+ {
+ /* PR 15140: Catch attempts to convert a normal
+ archive into a thin archive or vice versa. */
+ if (make_thin_archive && ! bfd_is_thin_archive (arch))
+ {
+ fatal (_("Cannot convert existing library %s to thin format"),
+ bfd_get_filename (arch));
+ goto bloser;
+ }
+ else if (! make_thin_archive && bfd_is_thin_archive (arch))
+ {
+ fatal (_("Cannot convert existing thin library %s to normal format"),
+ bfd_get_filename (arch));
+ goto bloser;
+ }
+ }
+
last_one = &(arch->archive_next);
/* Read all the contents right away, regardless. */
for (next_one = bfd_openr_next_archived_file (arch, NULL);