aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2021-07-02 09:41:12 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2021-07-02 09:41:12 +0000
commitc2e77482ce6ae9b1f0deb05035fb7530fb7208af (patch)
treeb9b027af6f181031574ee05829b5fba078b01f2b
parentc353e8424c67c19df81f8cdff1d9c431db66a504 (diff)
parent3edbac816828a0beb129ba18a3eee3c4625d7fc1 (diff)
downloadlibcppbor-android-mainline-12.0.0_r27.tar.gz
Change-Id: Idadaec632385f4c1d9bc9fe6951d342dcc986794
-rw-r--r--src/cppbor_parse.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/cppbor_parse.cpp b/src/cppbor_parse.cpp
index f5e8fcf..964a72d 100644
--- a/src/cppbor_parse.cpp
+++ b/src/cppbor_parse.cpp
@@ -96,7 +96,8 @@ std::tuple<const uint8_t*, ParseClient*> handleString(uint64_t length, const uin
const uint8_t* valueBegin, const uint8_t* end,
const std::string& errLabel,
ParseClient* parseClient) {
- if (end - valueBegin < static_cast<ssize_t>(length)) {
+ ssize_t signed_length = static_cast<ssize_t>(length);
+ if (end - valueBegin < signed_length || signed_length < 0) {
parseClient->error(hdrBegin, insufficientLengthString(length, end - valueBegin, errLabel));
return {hdrBegin, nullptr /* end parsing */};
}