[DebugInfo] Add checks for v2 directory and file name table terminators
authorJames Henderson <james.henderson@sony.com>
Wed, 12 Feb 2020 14:37:10 +0000 (14:37 +0000)
committerJames Henderson <james.henderson@sony.com>
Wed, 12 Feb 2020 14:49:22 +0000 (14:49 +0000)
commitbf4d8f29524449c4114b457875cc6a8031c46092
treed96b22ce18e5bfa0163919b87651231dbd5336e8
parent23cf0a30b1528cf268ffdf13e04a5baa7eddfe0a
[DebugInfo] Add checks for v2 directory and file name table terminators

The DWARFv2-4 specification for the line table header states that the
include directories and file name tables both end with a single null
byte. Prior to this change, the parser did not detect if this byte was
missing, because it also stopped reading the tables once it reached the
prologue end, as claimed by the header_length field. This change adds a
check that the terminator has been seen at the end of each table.

Reviewed by: dblaikie, MaskRay

Differential Revision: https://reviews.llvm.org/D74413
llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
llvm/test/tools/llvm-dwarfdump/X86/Inputs/debug_line_malformed.s
llvm/test/tools/llvm-dwarfdump/X86/debug_line_invalid.test
llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp