diff --git a/base/src/parcel.cpp b/base/src/parcel.cpp index 09bb4aaff8295bb7c7af6814573333af83805c6e..d893964bb2d9111d9ddc1365ba1149872a04ad9f 100644 --- a/base/src/parcel.cpp +++ b/base/src/parcel.cpp @@ -429,6 +429,10 @@ bool Parcel::WriteBufferAddTerminator(const void *data, size_t size, size_t type // Reserved for 32 bits const char terminator[] = {0, 0, 0, 0}; + if (typeSize > sizeof(terminator)) { + UTILS_LOGE("invalid typeSize, typeSize: %{public}zu", typeSize); + return false; + } if (!WriteDataBytes(terminator, typeSize)) { return false; }