代码拉取完成,页面将自动刷新
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
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。