summaryrefslogtreecommitdiff
path: root/binutils/elfcomm.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/elfcomm.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/elfcomm.c')
-rw-r--r--binutils/elfcomm.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/binutils/elfcomm.c b/binutils/elfcomm.c
index 64d4b21398..1179a1aac5 100644
--- a/binutils/elfcomm.c
+++ b/binutils/elfcomm.c
@@ -1,6 +1,5 @@
/* elfcomm.c -- common code for ELF format file.
- Copyright 2010
- Free Software Foundation, Inc.
+ Copyright 2010-2013 Free Software Foundation, Inc.
Originally developed by Eric Youngdale <eric@andante.jic.com>
Modifications by Nick Clifton <nickc@redhat.com>
@@ -690,12 +689,20 @@ make_qualified_name (struct archive_info * arch,
struct archive_info * nested_arch,
const char *member_name)
{
+ const char * error_name = _("<corrupt>");
size_t len;
char * name;
len = strlen (arch->file_name) + strlen (member_name) + 3;
- if (arch->is_thin_archive && arch->nested_member_origin != 0)
- len += strlen (nested_arch->file_name) + 2;
+ if (arch->is_thin_archive
+ && arch->nested_member_origin != 0)
+ {
+ /* PR 15140: Allow for corrupt thin archives. */
+ if (nested_arch->file_name)
+ len += strlen (nested_arch->file_name) + 2;
+ else
+ len += strlen (error_name) + 2;
+ }
name = (char *) malloc (len);
if (name == NULL)
@@ -704,9 +711,16 @@ make_qualified_name (struct archive_info * arch,
return NULL;
}
- if (arch->is_thin_archive && arch->nested_member_origin != 0)
- snprintf (name, len, "%s[%s(%s)]", arch->file_name,
- nested_arch->file_name, member_name);
+ if (arch->is_thin_archive
+ && arch->nested_member_origin != 0)
+ {
+ if (nested_arch->file_name)
+ snprintf (name, len, "%s[%s(%s)]", arch->file_name,
+ nested_arch->file_name, member_name);
+ else
+ snprintf (name, len, "%s[%s(%s)]", arch->file_name,
+ error_name, member_name);
+ }
else if (arch->is_thin_archive)
snprintf (name, len, "%s[%s]", arch->file_name, member_name);
else