diff --git a/services/common/include/dinput_softbus_define.h b/services/common/include/dinput_softbus_define.h index 70dd253ac072f925df4ab79688052c81c197fb1c..e9b1579dff318a92aade13291af84fc2a112651c 100644 --- a/services/common/include/dinput_softbus_define.h +++ b/services/common/include/dinput_softbus_define.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -35,7 +35,7 @@ namespace DistributedInput { }; const int32_t ENCRYPT_TAG_LEN = 32; - const int32_t MSG_MAX_SIZE = 45 * 1024; + const uint32_t MSG_MAX_SIZE = 45 * 1024; const uint32_t SESSION_NAME_SIZE_MAX = 256; const uint32_t DEVICE_ID_SIZE_MAX = 65; diff --git a/services/transportbase/src/distributed_input_transport_base.cpp b/services/transportbase/src/distributed_input_transport_base.cpp index ad8a335471226f235cfdfdb62effb286879e57e3..278ea32845f75eaff45f1230da86a37218ac50db 100644 --- a/services/transportbase/src/distributed_input_transport_base.cpp +++ b/services/transportbase/src/distributed_input_transport_base.cpp @@ -466,7 +466,7 @@ bool DistributedInputTransportBase::CheckRecivedData(const std::string &message) void DistributedInputTransportBase::OnBytesReceived(int32_t sessionId, const void *data, uint32_t dataLen) { - if (sessionId < 0 || data == nullptr || dataLen <= 0) { + if (sessionId < 0 || data == nullptr || dataLen == 0 || dataLen > MSG_MAX_SIZE) { DHLOGE("OnBytesReceived param check failed"); return; }