9 Star 0 Fork 5

src-openEuler/secDetector

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Backport-check-value-for-topic.patch 1.36 KB
一键复制 编辑 原始数据 按行查看 历史
zgzxx 提交于 2023-11-22 18:41 . backport patch to check value for topic
From 585ac671ed21faa9d84cbab1609f2557857e5204 Mon Sep 17 00:00:00 2001
From: zgzxx <zhangguangzhi3@huawei.com>
Date: Tue, 21 Nov 2023 21:21:26 +0800
Subject: [PATCH] check value for topic
---
lib/secDetector_sdk.cpp | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/lib/secDetector_sdk.cpp b/lib/secDetector_sdk.cpp
index 208f4ac..ee76079 100644
--- a/lib/secDetector_sdk.cpp
+++ b/lib/secDetector_sdk.cpp
@@ -18,7 +18,7 @@
#include <iostream>
#include "../observer_agent/grpc_comm/grpc_api.h"
-#define ALLTOPIC 0x008FFFFF
+#define ALLTOPIC 0x00FFFFFF
using namespace std;
static string server_address("unix:///var/run/secDetector.sock");
static PubSubClient g_client(grpc::CreateChannel(server_address, grpc::InsecureChannelCredentials()));
@@ -32,8 +32,10 @@ extern "C" {
void *secSub(const int topic)
{
- if (!(topic & ALLTOPIC))
+ if (topic <= 0 || topic > ALLTOPIC) {
+ printf("secSub failed, topic:%d is error\n", topic);
return NULL;
+ }
unique_ptr<ClientReader<Message>> reader = g_client.Subscribe(topic);
@@ -47,8 +49,10 @@ void *secSub(const int topic)
void secUnsub(const int topic, void *reader)
{
- if (!(topic & ALLTOPIC))
- return;
+ if (topic <= 0 || topic > ALLTOPIC) {
+ printf("secUnsub failed, topic:%d is error\n", topic);
+ return;
+ }
if (!reader)
return;
--
2.33.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler/secDetector.git
git@gitee.com:src-openeuler/secDetector.git
src-openeuler
secDetector
secDetector
master

搜索帮助