llvm-project/clang/unittests/Lex
Duncan P. N. Exon Smith 96a01fa046 Lex: Never overflow the file in HeaderMap::lookupFilename()
If a header map file is corrupt, the strings in the string table may not
be null-terminated.  The logic here previously relied on `MemoryBuffer`
always being null-terminated, but this isn't actually guaranteed by the
class AFAICT.  Moreover, we're seeing a lot of crash traces at calls to
`strlen()` inside of `lookupFilename()`, so something is going wrong
there.

Instead, use `strnlen()` to get the length, and check for corruption.

Also remove code paths that could call `StringRef(nullptr)`.  r261459
made these rather obvious (although they'd been there all along).

llvm-svn: 261461
2016-02-21 00:14:36 +00:00
..
CMakeLists.txt Lex: Add some unit tests for corrupt header maps 2016-02-20 20:39:51 +00:00
HeaderMapTest.cpp Lex: Never overflow the file in HeaderMap::lookupFilename() 2016-02-21 00:14:36 +00:00
LexerTest.cpp Fix -Wextra-semi warnings. 2015-07-22 20:46:26 +00:00
PPCallbacksTest.cpp [VFS] Use VFS instead of virtual files in PPCallbacks test. 2015-10-08 14:20:14 +00:00
PPConditionalDirectiveRecordTest.cpp Fix -Wextra-semi warnings. 2015-07-22 20:46:26 +00:00