diff options
author | Hasini Gunasinghe <hasinitg@google.com> | 2022-01-12 08:13:11 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2022-01-12 08:13:11 +0000 |
commit | 37233f718c575bda8daf65e7eefc32b94c2fc385 (patch) | |
tree | e4999d184f7c314c2be9a80cdb8c023158b36921 | |
parent | 69563572068f33fceccf3337be0204c5ea252dac (diff) | |
parent | 2c9da42d4c7c5aad7ff4fb0c0741259f70e8d411 (diff) | |
download | libcppbor-37233f718c575bda8daf65e7eefc32b94c2fc385.tar.gz |
Add input validation for 'parseRecursively' method. am: 8f4908840c am: 2c9da42d4c
Original change: https://googleplex-android-review.googlesource.com/c/platform/external/libcppbor/+/16607343
Change-Id: Icc62947c774d227e6637970abe88a66b200cec6a
-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..9d388a3 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. Begin and end cannot point to the same location."); + return {begin, nullptr}; + } + const uint8_t* pos = begin; MajorType type = static_cast<MajorType>(*pos & 0xE0); |