diff --git a/framework/common/udmf_types_util.cpp b/framework/common/udmf_types_util.cpp index ad2d572398651023d2721eb4a620d16e8d3c3e54..47b9aa896daeed6756de6fd35dca1e73259dd73a 100644 --- a/framework/common/udmf_types_util.cpp +++ b/framework/common/udmf_types_util.cpp @@ -43,8 +43,8 @@ template<> bool Unmarshalling(UnifiedData &output, MessageParcel &parcel) { auto size = parcel.ReadInt32(); - if (size == 0) { - LOG_ERROR(UDMF_SERVICE, "UnifiedData is empty!"); + if (size <= 0 || size > UnifiedData::MAX_DATA_SIZE) { + LOG_ERROR(UDMF_SERVICE, "UnifiedData is empty or too large!"); return false; } auto rawData = parcel.ReadRawData(size); @@ -84,8 +84,8 @@ template<> bool Unmarshalling(std::vector &output, MessageParcel &parcel) { auto size = parcel.ReadInt32(); - if (size == 0) { - LOG_ERROR(UDMF_SERVICE, "UnifiedDataSet is empty!"); + if (size <= 0 || size > UnifiedData::MAX_DATA_SIZE) { + LOG_ERROR(UDMF_SERVICE, "UnifiedDataSet is empty or too large!"); return false; } const uint8_t *rawData = reinterpret_cast(parcel.ReadRawData(size));