aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHasini Gunasinghe <hasinitg@google.com>2022-01-21 01:50:17 +0000
committerHasini Gunasinghe <hasinitg@google.com>2022-01-21 01:50:17 +0000
commit31258214ed9360e5848889f1b9a68cc5845cc8cb (patch)
tree52bb07b055777dc81d6ea4023d57d6b2215f4fc3
parent9424732f83df8fcdb601b77d3aa3e346583c77cb (diff)
downloadlibcppbor-31258214ed9360e5848889f1b9a68cc5845cc8cb.tar.gz
Bug: 192743373 Test: To be verified with fuzzer test case. Merged-In: If052fcb2b2bbc5e0bfc8cfccc51cef11b9914017 Change-Id: I0b553d58863aaa85004a7bc576fb524df31af44a
-rw-r--r--src/cppbor_parse.cpp7
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);