diff options
author | Alan Modra <amodra@gmail.com> | 2010-11-18 07:54:07 +0000 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2010-11-18 07:54:07 +0000 |
commit | 3832723d11b381c5d2930834f2cc33dfae25819e (patch) | |
tree | 28d265a412a80224777499ef24d487904d141186 /binutils | |
parent | 99753d9d70bc219217ea4045eebf8ecb778720ac (diff) | |
download | gdb-3832723d11b381c5d2930834f2cc33dfae25819e.zip gdb-3832723d11b381c5d2930834f2cc33dfae25819e.tar.gz gdb-3832723d11b381c5d2930834f2cc33dfae25819e.tar.bz2 |
PR binutils/11742
* readelf.c (get_archive_member_name): Formatting. Properly
handle full size ar_name.
Diffstat (limited to 'binutils')
-rw-r--r-- | binutils/ChangeLog | 6 | ||||
-rw-r--r-- | binutils/readelf.c | 41 |
2 files changed, 34 insertions, 13 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog index b5f0e10..d1300fc 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,9 @@ +2010-11-18 Alan Modra <amodra@gmail.com> + + PR binutils/11742 + * readelf.c (get_archive_member_name): Formatting. Properly + handle full size ar_name. + 2010-11-17 Alan Modra <amodra@gmail.com> * ar.c (print_contents): Don't internationalize strings without words. diff --git a/binutils/readelf.c b/binutils/readelf.c index caacb14..8c20888 100644 --- a/binutils/readelf.c +++ b/binutils/readelf.c @@ -12831,14 +12831,20 @@ get_archive_member_name (struct archive_info * arch, /* This is a proxy for a member of a nested archive. Find the name of the member in that archive. */ - member_file_name = adjust_relative_path (arch->file_name, arch->longnames + k, j - k); + member_file_name = adjust_relative_path (arch->file_name, + arch->longnames + k, j - k); if (member_file_name != NULL - && setup_nested_archive (nested_arch, member_file_name) == 0 - && (member_name = get_archive_member_name_at (nested_arch, arch->nested_member_origin, NULL)) != NULL) - { - free (member_file_name); - return member_name; - } + && setup_nested_archive (nested_arch, member_file_name) == 0) + { + member_name = get_archive_member_name_at (nested_arch, + arch->nested_member_origin, + NULL); + if (member_name != NULL) + { + free (member_file_name); + return member_name; + } + } free (member_file_name); /* Last resort: just return the name of the nested archive. */ @@ -12846,12 +12852,21 @@ get_archive_member_name (struct archive_info * arch, } /* We have a normal (short) name. */ - j = 0; - while ((arch->arhdr.ar_name[j] != '/') - && (j < sizeof (arch->arhdr.ar_name) - 1)) - j++; - arch->arhdr.ar_name[j] = '\0'; - return arch->arhdr.ar_name; + for (j = 0; j < sizeof (arch->arhdr.ar_name); j++) + if (arch->arhdr.ar_name[j] == '/') + { + arch->arhdr.ar_name[j] = '\0'; + return arch->arhdr.ar_name; + } + + /* The full ar_name field is used. Don't rely on ar_date starting + with a zero byte. */ + { + char *name = xmalloc (sizeof (arch->arhdr.ar_name) + 1); + memcpy (name, arch->arhdr.ar_name, sizeof (arch->arhdr.ar_name)); + name[sizeof (arch->arhdr.ar_name)] = '\0'; + return name; + } } /* Get the name of an archive member at a given OFFSET within an archive ARCH. */ |