diff --git a/services/implementation/src/attest/dm_auth_attest_common.cpp b/services/implementation/src/attest/dm_auth_attest_common.cpp index 50a43b60af2ceefb13bc0c9bc0628d0de1ce50c9..deec44d104da7dbf1b33900e0ca72c217b676770 100644 --- a/services/implementation/src/attest/dm_auth_attest_common.cpp +++ b/services/implementation/src/attest/dm_auth_attest_common.cpp @@ -23,6 +23,7 @@ namespace DistributedHardware { const int32_t MAX_CERT_COUNT = 100; constexpr int32_t HEX_TO_UINT8 = 2; +const int32_t MAX_LEN_PER_CERT = 8192; AuthAttestCommon::AuthAttestCommon() { @@ -45,8 +46,8 @@ std::string AuthAttestCommon::SerializeDmCertChain(const DmCertChain *chain) JsonObject jsonArrayObj(JsonCreateType::JSON_CREATE_TYPE_ARRAY); for (uint32_t i = 0; i < chain->certCount; ++i) { const DmBlob &blob = chain->cert[i]; - if (blob.data == nullptr || blob.size == 0) { - LOGE("blob data or size is empty."); + if (blob.data == nullptr || blob.size == 0 || blob.size > MAX_LEN_PER_CERT) { + LOGE("Invalid blob: null data or invalid size."); return "{}"; } const uint32_t hexLen = blob.size * HEX_TO_UINT8 + 1; // 2*blob.size + 1 diff --git a/services/service/src/hichain/hichain_listener.cpp b/services/service/src/hichain/hichain_listener.cpp index b6ffdedb7c65c9f5bc6c089cbf7d9663f06ae68e..1779410c6d9a709ab748459cc7ceb087e551ff10 100644 --- a/services/service/src/hichain/hichain_listener.cpp +++ b/services/service/src/hichain/hichain_listener.cpp @@ -186,7 +186,7 @@ void HichainListener::OnCredentialDeleted(const char *credId, const char *credIn uint32_t credType = 0; std::string credTypeTag = "credType"; if (IsInt32(jsonObject, credTypeTag)) { - credType = jsonObject[credTypeTag].Get(); + credType = static_cast(jsonObject[credTypeTag].Get()); } if (credType != ACCOUNT_SHARED) { LOGE("credType %{public}d is invalid.", credType);