1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-20 03:23:01 +02:00
llvm-mirror/lib/Support
Thomas Finch 7f44300477 YAML parser robustness improvements
Summary: This patch fixes a number of bugs found in the YAML parser
through fuzzing. In general, this makes the parser more robust against
malformed inputs.

The fixes are mostly improved null checking and returning errors in
more cases. In some cases, asserts were changed to regular errors,
this provides the same robustness but also protects release builds
from the triggering conditions. This also improves the fuzzability of
the YAML parser since asserts can act as a roadblock to further
fuzzing once they're hit.

Each fix has a corresponding test case:
  - TestAnchorMapError - Added proper null pointer handling in
    `Stream::printError` if N is null and `KeyValueNode::getValue` if
    getKey returns null, `Input::createHNodes` `dyn_casts` changed to
    `dyn_cast_or_null` so the null pointer checks are actually able to
    fail
  - TestFlowSequenceTokenErrors - Added case in
    `Document::parseBlockNode` for FlowMappingEnd, FlowSequenceEnd, or
    FlowEntry tokens outside of mappings or sequences
  - TestDirectiveMappingNoValue - Changed assert to regular error
    return in `Scanner::scanValue`
  - TestUnescapeInfiniteLoop - Fixed infinite loop in
    `ScalarNode::unescapeDoubleQuoted` by returning an error for
    unrecognized escape codes
  - TestScannerUnexpectedCharacter - Changed asserts to regular error
    returns in `Scanner::consume`
  - TestUnknownDirective - For both of the inputs the stream doesn't
    fail and correctly returns TK_Error, but there is no valid root
    node for the document. There's no reasonable way to make the
    scanner fail for unknown directives without breaking the YAML spec
    (see spec-07-01.test). I think the assert is unnecessary given
    that an error is still generated for this case.

The `SimpleKeys.clear()` line fixes a bug found by AddressSanitizer
triggered by multiple test cases - when TokenQueue is cleared
SimpleKeys is still holding dangling pointers into it, so SimpleKeys
should be cleared as well.

Patch by Thomas Finch!

Reviewers: chandlerc, Bigcheese, hintonda

Reviewed By: Bigcheese, hintonda

Subscribers: hintonda, kristina, beanz, dexonsmith, hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D61608
2019-11-05 21:51:04 -08:00
..
Unix [Support] Use /proc/self/exe for GNU Hurd 2019-11-01 17:27:27 +00:00
Windows Revert "Disable exit-on-SIGPIPE in lldb" 2019-10-24 13:19:49 -07:00
AArch64TargetParser.cpp [AArch64][SVE2] Rename bitperm feature to sve2-bitperm 2019-07-26 15:57:50 +00:00
ABIBreak.cpp Move LLVM_ENABLE_ABI_BREAKING_CHECKS variables to their own file 2019-09-10 22:05:01 +00:00
Allocator.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
AMDGPUMetadata.cpp [AMDGPU] Added a new metadata for multi grid sync implicit argument 2019-07-05 16:05:17 +00:00
APFloat.cpp [clang] Add storage for APValue in ConstantExpr 2019-06-15 10:24:47 +00:00
APInt.cpp [APInt] Introduce APIntOps::GetMostSignificantDifferentBit() 2019-10-26 23:20:58 +03:00
APSInt.cpp Fix parameter name comments using clang-tidy. NFC. 2019-07-16 04:46:31 +00:00
ARMAttributeParser.cpp ARMAttributeParser - fix shadow variable name warnings from decodeULEB128 calls. NFCI. 2019-11-02 20:12:59 +00:00
ARMBuildAttrs.cpp [ARM] add target arch definitions for 8.1-M and MVE 2019-05-30 12:57:04 +00:00
ARMTargetParser.cpp [ARM] VFPv2 only supports 16 D registers. 2019-09-17 21:42:38 +00:00
ARMWinEH.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
Atomic.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
BinaryStreamError.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
BinaryStreamReader.cpp [Support] Add LEB128 support to BinaryStreamReader/Writer. 2019-04-17 15:38:27 +00:00
BinaryStreamRef.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
BinaryStreamWriter.cpp [Support] Add LEB128 support to BinaryStreamReader/Writer. 2019-04-17 15:38:27 +00:00
BlockFrequency.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
BranchProbability.cpp [BranchProbability] Delete a redundant overflow check 2019-06-15 10:09:59 +00:00
BuryPointer.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
CachePruning.cpp Rename F_{None,Text,Append} to OF_{None,Text,Append}. NFC 2019-08-05 05:43:48 +00:00
Chrono.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
circular_raw_ostream.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
CMakeLists.txt Unify the two CRC implementations 2019-10-09 09:06:30 +00:00
CodeGenCoverage.cpp [llvm] Migrate llvm::make_unique to std::make_unique 2019-08-15 15:54:37 +00:00
COM.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
CommandLine.cpp Expose ProvidePositionalOption as a public API 2019-10-05 01:37:04 +00:00
Compression.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
ConvertUTF.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
ConvertUTFWrapper.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
COPYRIGHT.regex
CrashRecoveryContext.cpp minor doc typo fix / testing github commit 2019-10-28 12:08:40 +01:00
CRC.cpp Unify the two CRC implementations 2019-10-09 09:06:30 +00:00
DAGDeltaAlgorithm.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
DataExtractor.cpp Add error handling to the DataExtractor class 2019-08-27 11:24:08 +00:00
Debug.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
DebugCounter.cpp Print out DebugCounter info with -print-debug-counter 2018-10-23 21:51:56 +00:00
DeltaAlgorithm.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
DJB.cpp [DJB] Fix variable case after D61178 2019-04-27 15:33:22 +00:00
DynamicLibrary.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
Errno.cpp Remove some autoconf references from docs and comments 2019-07-03 09:57:59 +00:00
Error.cpp Move LLVM_ENABLE_ABI_BREAKING_CHECKS variables to their own file 2019-09-10 22:05:01 +00:00
ErrorHandling.cpp [Support] Move the static initializer install_out_memory_new_handler to InitLLVM 2019-07-12 16:23:25 +00:00
FileCheck.cpp [FileCheck] Implement --ignore-case option. 2019-10-11 11:59:14 +00:00
FileCheckImpl.h [FileCheck] Implement --ignore-case option. 2019-10-11 11:59:14 +00:00
FileCollector.cpp Rename F_{None,Text,Append} to OF_{None,Text,Append}. NFC 2019-08-05 05:43:48 +00:00
FileOutputBuffer.cpp [LLD][ELF] Support --[no-]mmap-output-file with F_no_mmap 2019-10-29 15:49:08 -07:00
FileUtilities.cpp Revert "r372201: [Support] Replace function with function_ref in writeFileAtomically. NFC" 2019-09-18 08:47:09 +00:00
FoldingSet.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
FormattedStream.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
FormatVariadic.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
GlobPattern.cpp Reapply r375051: [support] GlobPattern: add support for \ and [!...], and allow ] in more places 2019-10-17 18:09:05 +00:00
GraphWriter.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
Hashing.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
Host.cpp Implement sys::getHostCPUName() for Darwin ARM 2019-11-05 17:49:16 -08:00
InitLLVM.cpp [Support] Move the static initializer install_out_memory_new_handler to InitLLVM 2019-07-12 16:23:25 +00:00
IntEqClasses.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
IntervalMap.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
ItaniumManglingCanonicalizer.cpp [demangle] NFC: get rid of NodeOrString 2019-11-04 12:17:12 -08:00
JSON.cpp [llvm] Migrate llvm::make_unique to std::make_unique 2019-08-15 15:54:37 +00:00
KnownBits.cpp [KnownBits] Add computeForAddCarry() 2019-04-12 18:18:08 +00:00
LEB128.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
LineIterator.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
LLVMBuild.txt Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
Locale.cpp [Windows] Convert from UTF-8 to UTF-16 when writing to a Windows console 2018-09-05 00:08:56 +00:00
LockFileManager.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
LowLevelType.cpp Fix parameter name comments using clang-tidy. NFC. 2019-07-16 04:46:31 +00:00
ManagedStatic.cpp [Support] Replace sys::Mutex with their standard equivalents. 2019-08-19 19:49:57 +00:00
MathExtras.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
MD5.cpp Remove \brief commands from doxygen comments. 2018-05-01 15:54:18 +00:00
Memory.cpp [Support] Renamed member 'Size' to 'AllocatedSize' in MemoryBlock and OwningMemoryBlock. 2019-05-20 20:53:05 +00:00
MemoryBuffer.cpp [Support] Improve readNativeFile(Slice) interface 2019-08-22 08:13:30 +00:00
NativeFormatting.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
Optional.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
Options.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
Parallel.cpp win: Move Parallel.h off concrt to cross-platform code 2019-10-10 18:57:23 +00:00
Path.cpp [Path] Fix bug in make_absolute logic 2019-08-06 15:46:45 +00:00
PluginLoader.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
PrettyStackTrace.cpp Make GCC happy about attribute location 2019-07-25 16:58:15 +00:00
Process.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
Program.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
RandomNumberGenerator.cpp [CommandLine] Provide parser<unsigned long> instantiation to allow cl::opt<uint64_t> on LP64 platforms 2019-04-24 02:40:20 +00:00
raw_os_ostream.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
raw_ostream.cpp Revert "raw_ostream: add operator<< overload for std::error_code" 2019-08-14 13:59:04 +00:00
regcomp.c Allow Compiler.h to be included in C files and fix fallthrough warnings 2019-08-23 17:25:21 +00:00
regengine.inc [ADT] Replace std::isprint by llvm::isPrint. 2018-07-26 15:31:41 +00:00
regerror.c
regex2.h
regex_impl.h Remove trailing space 2018-07-30 19:41:25 +00:00
Regex.cpp Regex: Make "match" and "sub" const member functions 2019-09-24 14:42:36 +00:00
regexec.c
regfree.c
regstrlcpy.c
regutils.h
RWMutex.cpp [RWMutex] Simplify availability check 2019-08-16 21:25:40 +00:00
ScaledNumber.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
ScopedPrinter.cpp
SHA1.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
Signals.cpp Only use argv[0] as the main executable name if it exists. 2019-04-15 22:07:56 +00:00
Signposts.cpp [Support] Fix Wundef warning 2019-08-15 10:05:22 +00:00
SmallPtrSet.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
SmallVector.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
SourceMgr.cpp Simplify std::lower_bound with llvm::{bsearch,lower_bound}. NFC 2019-06-21 05:40:31 +00:00
SpecialCaseList.cpp [llvm] Migrate llvm::make_unique to std::make_unique 2019-08-15 15:54:37 +00:00
Statistic.cpp [Stats] Add ALWAYS_ENABLED_STATISTIC enabled regardless of LLVM_ENABLE_STATS. 2019-10-11 00:57:41 +00:00
StringExtras.cpp Print quoted backslashes in LLVM IR as \\ instead of \5C 2019-10-10 18:31:57 +00:00
StringMap.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
StringPool.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
StringRef.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
StringSaver.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
SymbolRemappingReader.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
SystemUtils.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
TargetParser.cpp [AMDGPU] gfx908 target 2019-07-09 18:10:06 +00:00
TargetRegistry.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
TarWriter.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
Threading.cpp Reland "[Support] Add a way to run a function on a detached thread"" 2019-10-23 15:51:44 +02:00
ThreadLocal.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
ThreadPool.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
TimeProfiler.cpp Fix time-trace breaking flame graph assumptions 2019-09-05 09:26:04 +00:00
Timer.cpp [llvm] Migrate llvm::make_unique to std::make_unique 2019-08-15 15:54:37 +00:00
ToolOutputFile.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
TrigramIndex.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
Triple.cpp [triple] Use 'macabi' environment name for the Mac Catalyst triples 2019-07-03 01:02:43 +00:00
Twine.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
Unicode.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
UnicodeCaseFold.cpp Resubmit r325107 (case folding DJB hash) 2018-02-21 22:36:31 +00:00
Valgrind.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
VersionTuple.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
VirtualFileSystem.cpp VirtualFileSystem - fix uninitialized variable warnings. NFCI. 2019-11-04 17:24:35 +00:00
Watchdog.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
WithColor.cpp Revert r367649: Improve raw_ostream so that you can "write" colors using operator<< 2019-08-02 07:22:34 +00:00
xxhash.cpp Make ICF log output order deterministic. 2018-07-31 18:04:58 +00:00
YAMLParser.cpp YAML parser robustness improvements 2019-11-05 21:51:04 -08:00
YAMLTraits.cpp YAML parser robustness improvements 2019-11-05 21:51:04 -08:00
Z3Solver.cpp [llvm] Migrate llvm::make_unique to std::make_unique 2019-08-15 15:54:37 +00:00