diff options
| author | Jonas Devlieghere <jonas@devlieghere.com> | 2018-01-05 10:03:02 +0000 |
|---|---|---|
| committer | Jonas Devlieghere <jonas@devlieghere.com> | 2018-01-05 10:03:02 +0000 |
| commit | cbf651f7399feea9ea8495af571d67d924b8ec11 (patch) | |
| tree | 40273021e1fdc02fed22bb5c0bbc71972cee7dfe /llvm/lib/DebugInfo | |
| parent | 1ad085b8081e270e6038bf39dfc84eb50c14d3af (diff) | |
| download | bcm5719-llvm-cbf651f7399feea9ea8495af571d67d924b8ec11.tar.gz bcm5719-llvm-cbf651f7399feea9ea8495af571d67d924b8ec11.zip | |
[DebugInfo] Don't crash when given invalid DWARFv5 line table prologue.
This patch replaces an assertion with an explicit check for the validity
of the FORM parameters. The assertion was triggered when the DWARFv5
line table contained a zero address size.
This fixes OSS-Fuzz Issue 4644
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=4644
Differential revision: https://reviews.llvm.org/D41615
llvm-svn: 321863
Diffstat (limited to 'llvm/lib/DebugInfo')
| -rw-r--r-- | llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp | 2 | ||||
| -rw-r--r-- | llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp | 15 |
2 files changed, 10 insertions, 7 deletions
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp index e5ef4eaceeb..861122cfbaf 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp @@ -268,7 +268,7 @@ bool DWARFDebugLine::Prologue::parse(const DWARFDataExtractor &DebugLineData, if (getVersion() >= 5) { if (!parseV5DirFileTables(DebugLineData, OffsetPtr, EndPrologueOffset, - getFormParams(), U, HasMD5, IncludeDirectories, + FormParams, U, HasMD5, IncludeDirectories, FileNames)) { fprintf(stderr, "warning: parsing line table prologue at 0x%8.8" PRIx64 diff --git a/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp b/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp index 44886de2e3d..769ac37aa0b 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp @@ -64,8 +64,9 @@ DWARFFormValue::getFixedByteSize(dwarf::Form Form, const DWARFFormParams Params) { switch (Form) { case DW_FORM_addr: - assert(Params.Version && Params.AddrSize && "Invalid Params for form"); - return Params.AddrSize; + if (Params) + return Params.AddrSize; + return None; case DW_FORM_block: // ULEB128 length L followed by L bytes. case DW_FORM_block1: // 1 byte length L followed by L bytes. @@ -86,8 +87,9 @@ DWARFFormValue::getFixedByteSize(dwarf::Form Form, return None; case DW_FORM_ref_addr: - assert(Params.Version && Params.AddrSize && "Invalid Params for form"); - return Params.getRefAddrByteSize(); + if (Params) + return Params.getRefAddrByteSize(); + return None; case DW_FORM_flag: case DW_FORM_data1: @@ -118,8 +120,9 @@ DWARFFormValue::getFixedByteSize(dwarf::Form Form, case DW_FORM_line_strp: case DW_FORM_sec_offset: case DW_FORM_strp_sup: - assert(Params.Version && Params.AddrSize && "Invalid Params for form"); - return Params.getDwarfOffsetByteSize(); + if (Params) + return Params.getDwarfOffsetByteSize(); + return None; case DW_FORM_data8: case DW_FORM_ref8: |

