Avoid integer overflow in DecodeEntry.

This commit is contained in:
Christopher Jeffrey 2022-06-18 08:06:05 -04:00
parent be8d520965
commit ab065d80c0
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -68,7 +68,8 @@ static inline const char* DecodeEntry(const char* p, const char* limit,
if ((p = GetVarint32Ptr(p, limit, value_length)) == nullptr) return nullptr;
}
if (static_cast<uint32_t>(limit - p) < (*non_shared + *value_length)) {
if (static_cast<uint64_t>(limit - p) <
(static_cast<uint64_t>(*non_shared) + *value_length)) {
return nullptr;
}
return p;