From 7b52029bd34763a95bc0cf9d99d57657bc32a3c5 Mon Sep 17 00:00:00 2001 From: wujianlin Date: Mon, 7 Apr 2025 11:44:21 +0800 Subject: [PATCH] Add typeSize check Issue:https://gitee.com/openharmony/commonlibrary_c_utils/issues/IBYYXJ?from=project-issue Signed-off-by: wujianlin --- base/src/parcel.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/base/src/parcel.cpp b/base/src/parcel.cpp index 09bb4aa..d893964 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; } -- Gitee