51 lines
1.4 KiB
Diff
51 lines
1.4 KiB
Diff
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
|
|
|