diff --git a/base/src/parcel.cpp b/base/src/parcel.cpp index 1dfe9311cf8100a0406f9d4a82731b06ce7fb432..f8f7c1f9dd9513aac3a5e9720fbb44652fa5d7c1 100644 --- a/base/src/parcel.cpp +++ b/base/src/parcel.cpp @@ -1013,11 +1013,14 @@ const std::u16string Parcel::ReadString16() int32_t dataLength = 0; size_t oldCursor = readCursor_; - if (!Read(dataLength) || dataLength < 0) { + if (!Read(dataLength) || dataLength < 0 || dataLength >= 2147483647) { + UTILS_LOGE("return dataLength %{public}d, %{public}p", dataLength, &dataLength); return std::u16string(); } + UTILS_LOGE("continue dataLength %{public}d, %{public}p", dataLength, &dataLength); size_t readCapacity = (static_cast(dataLength) + 1) * sizeof(char16_t); + UTILS_LOGE("done readCapacity %{public}zu, %{public}p", readCapacity, &readCapacity); if ((readCapacity > (static_cast(dataLength))) && (readCapacity <= GetReadableBytes())) { const uint8_t *str = ReadBuffer(readCapacity); if (str != nullptr) {