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]

Re: stop bogus dwarf killing objdump


Hi Nathan,

I had the misfortune to have an executable with bogus dwarf information.

Just to check - how did readelf cope with this corrupt binary ?



! while (stash->info_ptr < stash->info_ptr_end)
{
bfd_vma length;
unsigned int offset_size = addr_size;
--- 3023,3029 ----
BFD_ASSERT (addr_size == 4 || addr_size == 8);
/* Read each remaining comp. units checking each as they are read. */
! while (stash->info_ptr != stash->info_ptr_end)
{
bfd_vma length;
unsigned int offset_size = addr_size;

I do not like this change. A corrupt value in the length field of a comp unit could cause stash->info_ptr to be set beyond stash->info_ptr_end which could lead to all kinds of problems. Besides it is not needed because...


  	  each = parse_comp_unit (stash, length, info_ptr_unit,
  				  offset_size);
+ 	  if (!each)
+ 	    {
+ 	      /* The dwarf information is damaged, don't trust it any
+ 		 more.  */
+ 	      stash->info_ptr = stash->info_ptr_end;
+ 	      break;
+ 	    }

The break here will exit the while loop without ever testing stash->info_ptr (and so setting it to stash->info_ptr_end is redundant).


Please could you modify your patch to just check the return value from parse_comp_unit and break the loop if it is NULL ?

Cheers
  Nick


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