llvm-project/clang/lib
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
..
ARCMigrate Fix some Clang-tidy readability-redundant-control-flow warnings; other minor fixes. 2016-02-10 19:11:58 +00:00
AST pr26544: Bitfield layout with pragma pack and attributes "packed" and 2016-02-19 11:23:28 +00:00
ASTMatchers Add an AST matcher for real floating-point types. e.g., float, double, long double, but not complex. 2016-02-18 16:36:01 +00:00
Analysis Remove use of builtin comma operator. 2016-02-18 22:34:54 +00:00
Basic [modules] Flatten -fmodule-name= and -fmodule-implementation-of= into a single 2016-02-19 22:25:36 +00:00
CodeGen Fix handling of vaargs on PPC32 when going from regsave to overflow. 2016-02-20 08:31:24 +00:00
Driver [MSVC Compat] Implement -EHc semantics 2016-02-20 09:23:47 +00:00
Edit Remove autoconf support 2016-01-26 21:30:40 +00:00
Format clang-format: [JS] Support for (.. of ..) loops. 2016-02-11 13:24:15 +00:00
Frontend [MSVC Compat] Implement -EHc semantics 2016-02-20 09:23:47 +00:00
FrontendTool Revert r260265, "clang-cl: Support loading plugins on Windows" 2016-02-11 16:33:20 +00:00
Headers Remove a duplicate declaration specifier from _ReadBarrier 2016-02-20 00:57:00 +00:00
Index clangIndex requires LLVMIR as Core, since r260858 uses llvm/IR. 2016-02-15 04:29:36 +00:00
Lex Lex: Never overflow the file in HeaderMap::lookupFilename() 2016-02-21 00:14:36 +00:00
Parse [OpenCL] Generate metadata for opencl_unroll_hint attribute 2016-02-19 18:30:11 +00:00
Rewrite Remove use of builtin comma operator. 2016-02-18 22:34:54 +00:00
Sema [MSVC Compat] Implement -EHc semantics 2016-02-20 09:23:47 +00:00
Serialization Implement the likely resolution of core issue 253. 2016-02-19 01:52:46 +00:00
StaticAnalyzer [analyzer] Add checker callback for beginning of function. 2016-02-19 01:35:10 +00:00
Tooling Stop using "template" when printing qualtype names 2016-02-16 20:34:27 +00:00
CMakeLists.txt Fix build with various feature flag combinations 2014-07-14 22:17:22 +00:00