[PATCH] D39185: [llvm-dwarfdump] - Fix array out of bounds access crash.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 24 08:37:47 PDT 2017


>> +DWARFDie DWARFUnit::getFirstChild(const DWARFDebugInfoEntry *Die) {
>> +  if (!Die->hasChildren())
>> +    return DWARFDie();
>> +
>> +  // We do not want access out of bounds when parsing corrupted debug data.
>> +  size_t I = getDIEIndex(Die) + 1;
>> +  if (I >= DieArray.size())
>> +    return DWARFDie();
>> +  return DWARFDie(this, &DieArray[I]);
>> +}
>> +
>
>We don't have to signal error by returning Expected? If for some reason
>we know that an error will always be reported, LGTM.
>
>Cheers,
>Rafael

I believe we will always report "compile unit extends beyond" error for such case here:
https://github.com/llvm-mirror/llvm/blob/master/lib/DebugInfo/DWARF/DWARFUnit.cpp#L223
I think it is good place for that btw, as it scans over all DIEs and it is easy and place to early check that some part
of DIE tree was truncated.

Best regards,
George | Developer | Access Softek, Inc


More information about the llvm-commits mailing list