diff options
author | Hasini Gunasinghe <hasinitg@google.com> | 2022-01-21 01:50:17 +0000 |
---|---|---|
committer | Hasini Gunasinghe <hasinitg@google.com> | 2022-01-21 01:50:17 +0000 |
commit | 31258214ed9360e5848889f1b9a68cc5845cc8cb (patch) | |
tree | 52bb07b055777dc81d6ea4023d57d6b2215f4fc3 | |
parent | 9424732f83df8fcdb601b77d3aa3e346583c77cb (diff) | |
download | libcppbor-31258214ed9360e5848889f1b9a68cc5845cc8cb.tar.gz |
Add input validation for 'parseRecursively' method.android-t-preview-2android-t-preview-1android-t-beta-3android-s-v2-beta-3android-s-qpr3-beta-1android-t-preview-1android-s-v2-beta-3android-s-qpr3-beta-1
Bug: 192743373
Test: To be verified with fuzzer test case.
Merged-In: If052fcb2b2bbc5e0bfc8cfccc51cef11b9914017
Change-Id: I0b553d58863aaa85004a7bc576fb524df31af44a
-rw-r--r-- | src/cppbor_parse.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/cppbor_parse.cpp b/src/cppbor_parse.cpp index 964a72d..23ebd6b 100644 --- a/src/cppbor_parse.cpp +++ b/src/cppbor_parse.cpp @@ -195,6 +195,13 @@ std::tuple<const uint8_t*, ParseClient*> handleCompound( std::tuple<const uint8_t*, ParseClient*> parseRecursively(const uint8_t* begin, const uint8_t* end, bool emitViews, ParseClient* parseClient) { + if (begin == end) { + parseClient->error( + begin, + "Input buffer is empty."); + return {begin, nullptr}; + } + const uint8_t* pos = begin; MajorType type = static_cast<MajorType>(*pos & 0xE0); |