From d0453855187c12cbea0223e2d86ae51c3ff9fb2f Mon Sep 17 00:00:00 2001 From: lwx1155083 Date: Fri, 10 Mar 2023 15:18:51 +0800 Subject: [PATCH] Add validation to parcel.cpp. Issue:I6LQJS Test:NA Signed-off-by: lwx1155083 --- base/src/parcel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/src/parcel.cpp b/base/src/parcel.cpp index 65b15f4..1dfe931 100644 --- a/base/src/parcel.cpp +++ b/base/src/parcel.cpp @@ -1044,7 +1044,7 @@ bool Parcel::ReadString16(std::u16string &value) } size_t readCapacity = (static_cast(dataLength) + 1) * sizeof(char16_t); - if (readCapacity <= GetReadableBytes()) { + if ((readCapacity > (static_cast(dataLength))) && (readCapacity <= GetReadableBytes())) { const uint8_t *str = ReadBuffer(readCapacity); if (str != nullptr) { const auto *u16Str = reinterpret_cast(str); -- Gitee