]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Pull request #4732: Fix alias name
authorSteve Chew (stechew) <stechew@cisco.com>
Fri, 9 May 2025 00:05:53 +0000 (00:05 +0000)
committerPriyanka Bangalore Gurudev (prbg) <prbg@cisco.com>
Fri, 9 May 2025 00:05:53 +0000 (00:05 +0000)
Merge in SNORT/snort3 from ~STECHEW/snort3:oleksii_alias_fix to master

Squashed commit of the following:

commit e14bdcd2196c9151048a2afb8559a64ab6fb4358
Author: Oleksii Shumeiko <oshumeik@cisco.com>
Date:   Wed Apr 2 15:54:45 2025 +0300

    framework: make alias name internal to inspector instance

commit 32450f01541938b7e3b80d1b52df3ad172bf56c3
Author: Oleksii Shumeiko <oshumeik@cisco.com>
Date:   Wed Apr 2 14:07:16 2025 +0300

    managers: update formatting

src/framework/inspector.cc
src/framework/inspector.h
src/managers/inspector_manager.cc
src/managers/test/get_inspector_test.cc

index b30d86a87b4cf3bfa71a9543bbdae94dd2feb4b1..4747f240d0643f95d7438d647e8942ce2d3a6040 100644 (file)
@@ -26,6 +26,7 @@
 #include "main/thread_config.h"
 #include "protocols/packet.h"
 #include "stream/stream_splitter.h"
+#include "utils/util.h"
 
 namespace snort
 {
@@ -60,6 +61,7 @@ Inspector::~Inspector()
         assert(0 == ref_count[i]);
 
     delete[] ref_count;
+    delete[] alias_name;
 }
 
 bool Inspector::is_inactive()
@@ -148,6 +150,12 @@ void Inspector::set_thread_specific_data(void* tsd)
 void* Inspector::get_thread_specific_data() const
 { return thread_specific_data->data[get_instance_id()]; }
 
+void Inspector::set_alias_name(const char* name)
+{
+    delete[] alias_name;
+    alias_name = snort_strdup(name);
+}
+
 static const char* InspectorTypeNames[IT_MAX] =
 {
     "passive",
index 20a3d1993c2e0d72dc59507124e502f24c4580a3..090c02fa6e884e0d099257d974184bd50fb5a3dc 100644 (file)
@@ -43,7 +43,7 @@ struct SnortConfig;
 struct Packet;
 
 // this is the current version of the api
-#define INSAPI_VERSION ((BASE_API_VERSION << 16) | 2)
+#define INSAPI_VERSION ((BASE_API_VERSION << 16) | 3)
 
 struct InspectionBuffer
 {
@@ -160,9 +160,7 @@ public:
 
     const char* get_name() const;
 
-    void set_alias_name(const char* name)
-    { alias_name = name; }
-
+    void set_alias_name(const char*);
     const char* get_alias_name() const
     { return alias_name; }
 
@@ -210,7 +208,6 @@ private:
     std::shared_ptr<ThreadSpecificData> thread_specific_data;
     std::atomic_uint* ref_count;
     SnortProtocolId snort_protocol_id = 0;
-    // FIXIT-E Use std::string to avoid storing a pointer to external std::string buffers
     const char* alias_name = nullptr;
     uint64_t network_policy_user_id = 0;
     bool network_policy_user_id_set = false;
index 2e36f3a832ac22373d77e038362c422e1dd90681..e52698b3e2375d593cbc56a3c620958a18bd9472 100644 (file)
@@ -112,6 +112,7 @@ enum ReloadType
 
 typedef vector<PHObject> PHObjectList;
 typedef vector<PHObjectList*> PHTSObjectLists;
+
 struct ThreadSpecificHandlers
 {
     explicit ThreadSpecificHandlers(unsigned max)
@@ -145,9 +146,9 @@ struct PHInstance
 
     bool is_reloaded()
     {
-        return ((reload_type == RELOAD_TYPE_REENABLED)or
-                   (reload_type == RELOAD_TYPE_DELETED) or
-                   (reload_type == RELOAD_TYPE_NEW));
+        return reload_type == RELOAD_TYPE_REENABLED
+            or reload_type == RELOAD_TYPE_DELETED
+            or reload_type == RELOAD_TYPE_NEW;
     }
 
     ReloadType get_reload_type()
@@ -181,14 +182,17 @@ PHInstance::~PHInstance()
 typedef vector<PHObject*> PHGlobalList;
 typedef vector<PHClass*> PHClassList;
 typedef vector<PHInstance*> PHInstanceList;
+
 struct PHRemovedInstance
 {
     PHRemovedInstance(PHInstance* i, PHTSObjectLists& handlers)
         : instance(i), handlers(handlers)
     { }
+
     PHInstance* instance;
     PHTSObjectLists& handlers;
 };
+
 typedef vector<PHRemovedInstance> PHRemovedInstanceList;
 typedef list<Inspector*> PHList;
 
@@ -196,7 +200,6 @@ static PHGlobalList s_handlers;
 static PHList s_trash;
 static PHList s_trash2;
 static bool s_sorted = false;
-
 static PHTSObjectLists s_tl_handlers;
 
 void InspectorManager::global_init()
index 8842344293f3f10bad0bd4898ca0d353d7acc20d..5ce0e8aafa4e87454be98461cd7356629fea7cec 100644 (file)
@@ -90,6 +90,9 @@ const SnortConfig* SnortConfig::get_conf()
 Module::Module(const char* name, const char*) : name(name), help(nullptr), params(nullptr), list(false)
 { }
 
+void Inspector::set_alias_name(const char* n)
+{ alias_name = n; }
+
 class TestInspector : public Inspector
 {
 public: