diff --git a/interfaces/inner_kits/src/ipc/distributed_hardware_proxy.cpp b/interfaces/inner_kits/src/ipc/distributed_hardware_proxy.cpp index 68135245616bb038084456ace1c3c153433e4f12..415d8c814bc26bf97fb153515cd18fab1c089dc5 100644 --- a/interfaces/inner_kits/src/ipc/distributed_hardware_proxy.cpp +++ b/interfaces/inner_kits/src/ipc/distributed_hardware_proxy.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 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 @@ -49,7 +49,7 @@ int32_t DistributedHardwareProxy::RegisterPublisherListener(const DHTopic topic, DHLOGE("remote service is null"); return ERR_DH_FWK_SERVICE_REMOTE_IS_NULL; } - if (topic < DHTopic::TOPIC_MIN || topic > DHTopic::TOPIC_MAX) { + if (topic <= DHTopic::TOPIC_MIN || topic => DHTopic::TOPIC_MAX) { DHLOGE("Topic is invalid!"); return ERR_DH_FWK_PARA_INVALID; } @@ -98,7 +98,7 @@ int32_t DistributedHardwareProxy::UnregisterPublisherListener(const DHTopic topi DHLOGE("remote service is null"); return ERR_DH_FWK_SERVICE_REMOTE_IS_NULL; } - if (topic < DHTopic::TOPIC_MIN || topic > DHTopic::TOPIC_MAX) { + if (topic <= DHTopic::TOPIC_MIN || topic >= DHTopic::TOPIC_MAX) { DHLOGE("Topic is invalid!"); return ERR_DH_FWK_PARA_INVALID; } @@ -141,7 +141,7 @@ int32_t DistributedHardwareProxy::PublishMessage(const DHTopic topic, const std: DHLOGE("remote service is null"); return ERR_DH_FWK_SERVICE_REMOTE_IS_NULL; } - if (topic < DHTopic::TOPIC_MIN || topic > DHTopic::TOPIC_MAX) { + if (topic <= DHTopic::TOPIC_MIN || topic >= DHTopic::TOPIC_MAX) { DHLOGE("Topic is invalid!"); return ERR_DH_FWK_PARA_INVALID; } @@ -187,7 +187,7 @@ std::string DistributedHardwareProxy::QueryLocalSysSpec(QueryLocalSysSpecType sp DHLOGE("remote service is null"); return ""; } - if (spec < QueryLocalSysSpecType::MIN || spec > QueryLocalSysSpecType::MAX) { + if (spec <= QueryLocalSysSpecType::MIN || spec >= QueryLocalSysSpecType::MAX) { DHLOGE("Sys spec type is invalid!"); return ""; } diff --git a/interfaces/inner_kits/src/ipc/publisher_listener_stub.cpp b/interfaces/inner_kits/src/ipc/publisher_listener_stub.cpp index db73fa8a6c3876d5174ca8f9d6f848910ab53e3d..e56e56f77ca41dee9da8b8191f2876343866cb73 100644 --- a/interfaces/inner_kits/src/ipc/publisher_listener_stub.cpp +++ b/interfaces/inner_kits/src/ipc/publisher_listener_stub.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 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 @@ -40,7 +40,7 @@ int32_t PublisherListenerStub::OnRemoteRequest( switch (msgCode) { case IPublisherListener::Message::ON_MESSAGE: { DHTopic topic = static_cast(data.ReadUint32()); - if (topic < DHTopic::TOPIC_MIN || topic > DHTopic::TOPIC_MAX) { + if (topic <= DHTopic::TOPIC_MIN || topic >= DHTopic::TOPIC_MAX) { DHLOGE("Topic is invalid!"); return ERR_INVALID_DATA; } diff --git a/services/distributedhardwarefwkservice/src/ipc/publisher_listener_proxy.cpp b/services/distributedhardwarefwkservice/src/ipc/publisher_listener_proxy.cpp index fc281609e99cd28a8e013f95ea7e7d274db84891..117c74e25371aafed56ec1400d46ce469d602740 100644 --- a/services/distributedhardwarefwkservice/src/ipc/publisher_listener_proxy.cpp +++ b/services/distributedhardwarefwkservice/src/ipc/publisher_listener_proxy.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 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 @@ -36,7 +36,7 @@ void PublisherListenerProxy::OnMessage(const DHTopic topic, const std::string& m DHLOGE("Get Remote IRemoteObject failed"); return; } - if (topic < DHTopic::TOPIC_MIN || topic > DHTopic::TOPIC_MAX) { + if (topic <= DHTopic::TOPIC_MIN || topic >= DHTopic::TOPIC_MAX) { DHLOGE("Topic is invalid!"); return; }