diff options
author | Hasini Gunasinghe <hasinitg@google.com> | 2022-01-12 07:56:09 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2022-01-12 07:56:09 +0000 |
commit | 2c9da42d4c7c5aad7ff4fb0c0741259f70e8d411 (patch) | |
tree | e4999d184f7c314c2be9a80cdb8c023158b36921 | |
parent | 872b0aa4fc180fc81012be8196abe3930c5aeff8 (diff) | |
parent | 8f4908840cdd9cc2fe0442033516a273046598a2 (diff) | |
download | libcppbor-2c9da42d4c7c5aad7ff4fb0c0741259f70e8d411.tar.gz |
Add input validation for 'parseRecursively' method. am: 8f4908840c
Original change: https://googleplex-android-review.googlesource.com/c/platform/external/libcppbor/+/16607343
Change-Id: Ifd1fcd9db93e245451b43e0e86ba7d0c0a3206c5
-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); |