summaryrefslogtreecommitdiff
path: root/binutils/ar.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2013-02-15 14:37:34 +0000
committerNick Clifton <nickc@redhat.com>2013-02-15 14:37:34 +0000
commit504a4af911433852119075ab8c06506a93585473 (patch)
treebdf823f92c30e1d4d753c54137802438daaae450 /binutils/ar.c
parent8c9877db6f511c39cf496f65dc35c1780207c418 (diff)
downloadbinutils-redhat-504a4af911433852119075ab8c06506a93585473.tar.gz
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 0aa1ba3220..c424038f78 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);