mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Pass correct buffer length to parseDebugInfo() so as to avoid reading invalid Dwarf tag entry.
This commit is contained in:
parent
9b82edcc56
commit
cbcc62f9c4
2 changed files with 9 additions and 11 deletions
|
@ -348,7 +348,8 @@ public class Dwarf {
|
||||||
}
|
}
|
||||||
|
|
||||||
// read the abbrev section.
|
// read the abbrev section.
|
||||||
InputStream in = new ByteArrayInputStream(data, offset + 11, length);
|
// Note "length+4" is the total size in bytes of the CU data.
|
||||||
|
InputStream in = new ByteArrayInputStream(data, offset + 11, length+4-11);
|
||||||
Map abbrevs = parseDebugAbbreviation(header);
|
Map abbrevs = parseDebugAbbreviation(header);
|
||||||
parseDebugInfoEntry(requestor, in, abbrevs, header);
|
parseDebugInfoEntry(requestor, in, abbrevs, header);
|
||||||
|
|
||||||
|
|
|
@ -171,7 +171,7 @@ public class DwarfReader extends Dwarf implements ISymbolReader {
|
||||||
|
|
||||||
private void addSourceFile(String dir, String name)
|
private void addSourceFile(String dir, String name)
|
||||||
{
|
{
|
||||||
if (name == null)
|
if (name == null || name.length() == 0)
|
||||||
return;
|
return;
|
||||||
if (name.charAt(0) == '<') // don't count the entry "<internal>" from GCCE compiler
|
if (name.charAt(0) == '<') // don't count the entry "<internal>" from GCCE compiler
|
||||||
return;
|
return;
|
||||||
|
@ -237,16 +237,13 @@ public class DwarfReader extends Dwarf implements ISymbolReader {
|
||||||
|
|
||||||
// Override parent: only handle TAG_Compile_Unit.
|
// Override parent: only handle TAG_Compile_Unit.
|
||||||
void processDebugInfoEntry(IDebugEntryRequestor requestor, AbbreviationEntry entry, List list) {
|
void processDebugInfoEntry(IDebugEntryRequestor requestor, AbbreviationEntry entry, List list) {
|
||||||
int len = list.size();
|
|
||||||
int tag = (int) entry.tag;
|
int tag = (int) entry.tag;
|
||||||
for (int i = 0; i < len; i++) {
|
switch (tag) {
|
||||||
switch (tag) {
|
case DwarfConstants.DW_TAG_compile_unit :
|
||||||
case DwarfConstants.DW_TAG_compile_unit :
|
processCompileUnit(requestor, list);
|
||||||
processCompileUnit(requestor, list);
|
break;
|
||||||
break;
|
default:
|
||||||
default:
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue