This is the mail archive of the binutils@sourceware.org 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]
Other format: [Raw text]

Commit: readelf: Prevent seg-fault handling corrupt archives


Hi Guys,

  I am checking in the patch below to prevent a seg-fault in readelf
  when it is attempting to display the contents of a corrupt archive.

Cheers
  Nick

binutils/ChangeLog
2013-02-07  Nick Clifton  <nickc@redhat.com>

	* elfcomm.c (get_archive_member_name): Prevent seg-fault if a
	corrupt archive uses long names but has no long name table.

Index: binutils/elfcomm.c
===================================================================
RCS file: /cvs/src/src/binutils/elfcomm.c,v
retrieving revision 1.3
diff -u -3 -p -r1.3 elfcomm.c
--- binutils/elfcomm.c  17 Jul 2012 16:29:36 -0000      1.3
+++ binutils/elfcomm.c  7 Feb 2013 16:05:14 -0000
@@ -586,6 +586,12 @@ get_archive_member_name (struct archive_
       char *member_file_name;
       char *member_name;
 
+      if (arch->longnames == NULL || arch->longnames_size == 0)
+       {
+         error (_("Archive member uses long names, but no longname table found\n"));
+         return NULL;
+       }
+      
       arch->nested_member_origin = 0;
       k = j = strtoul (arch->arhdr.ar_name + 1, &endp, 10);
       if (arch->is_thin_archive && endp != NULL && * endp == ':')


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