]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #165 in SNORT/snort3 from crc/clang to master
authorRuss Combs (rucombs) <rucombs@cisco.com>
Thu, 3 Dec 2015 17:33:56 +0000 (12:33 -0500)
committerRuss Combs (rucombs) <rucombs@cisco.com>
Thu, 3 Dec 2015 17:33:56 +0000 (12:33 -0500)
Squashed commit of the following:

commit 32a6ac430b2ddda7782fb0d357c915900bcc2c93
Author: Russ Combs <rucombs@cisco.com>
Date:   Wed Dec 2 15:57:43 2015 -0500

    review updates

commit 3d1d209b73516f202695c49aabcea294bc9701ed
Author: Russ Combs <rucombs@cisco.com>
Date:   Wed Dec 2 07:03:34 2015 -0500

    fix clang related issues

configure.ac
src/ips_options/ips_regex.cc
src/network_inspectors/normalize/norm_module.cc
src/network_inspectors/normalize/norm_module.h

index bdd09eb689ba8dda4d0e541eb09647da9facc984..6d9f93dd2da228dbfc284c00632a55c3245e10aa 100644 (file)
@@ -764,10 +764,12 @@ LIBS="$LIBS -lz"
 # pthreads (optional)
 #--------------------------------------------------------------------------
 
-AX_PTHREAD
-LIBS="$PTHREAD_LIBS $LIBS"
-CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS"
-LDFLAGS="$LDFLAGS $PTHREAD_LDFLAGS"
+if test "x$CXX" = "xg++"; then
+    AX_PTHREAD
+    LIBS="$PTHREAD_LIBS $LIBS"
+    CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS"
+    LDFLAGS="$LDFLAGS $PTHREAD_LDFLAGS"
+fi
 
 #--------------------------------------------------------------------------
 # lzma (optional)
index 59c62c307b88a3fe1a8c0e4cafe8a1e90f1f64e8..c45b0117aec60285e6d427075029c9320886373b 100644 (file)
@@ -47,6 +47,9 @@ struct RegexConfig
     unsigned flags;
     bool relative;
 
+    RegexConfig()
+    { reset(); }
+
     void reset()
     {
         re.clear();
index 372b504884ed69a3fa9da86a78585f0621d91439..f42f9c30caa15f5805fc69411de8e4503afc15e5 100644 (file)
@@ -187,15 +187,29 @@ static const Parameter s_params[] =
 };
 
 //-------------------------------------------------------------------------
-// normalize parameters
+// normalize module
 //-------------------------------------------------------------------------
 
+// using string* instead of string because clang++ 5.1
+// vector::back() does not seem to return a reference 
+//
+// FIXIT-L these are static since get_pegs() is const
+// consider making that non-const
+std::vector<const std::string*> NormalizeModule::test_text;
+std::vector<PegInfo> NormalizeModule::test_pegs;
+
 NormalizeModule::NormalizeModule() :
     Module(NORM_NAME, NORM_HELP, s_params)
 {
     memset(&config, 0, sizeof(config));
 }
 
+NormalizeModule::~NormalizeModule()
+{
+    for ( auto s : test_text )
+        delete s;
+}
+
 ProfileStats* NormalizeModule::get_profile() const
 { return &norm_perf_stats; }
 
@@ -360,38 +374,35 @@ bool NormalizeModule::end(const char* fqn, int, SnortConfig*)
     return true;
 }
 
-static inline PegInfo createTestPeg(const PegInfo p)
+void NormalizeModule::add_test_peg(const PegInfo& norm) const
 {
-    // using a static vector to ensure the char* referred to in the PegInfo
-    // are valid after this function returns
-    static vector<std::string> test_pegs;
-    PegInfo test_peg;
-
-    std::string test_name("test ");
-    test_name.append(p.name);
-    test_pegs.push_back(test_name);
-    test_peg.name = test_pegs.back().c_str();
-
-    std::string test_info("During inline mode, would have ");
-    test_info.append(p.help);
-    test_pegs.push_back(test_info);
-    test_peg.help = test_pegs.back().c_str();
-
-    return test_peg;
+    PegInfo test;
+
+    std::string* test_name = new std::string("test ");
+    test_name->append(norm.name);
+    test_text.push_back(test_name);
+    test.name = test_text.back()->c_str();
+
+    std::string* test_info = new std::string("test ");
+    test_info->append(norm.help);
+    test_text.push_back(test_info);
+    test.help = test_text.back()->c_str();
+
+    test_pegs.push_back(test);
 }
 
 const PegInfo* NormalizeModule::get_pegs() const
 {
-    static vector<PegInfo> pegs;
-    pegs.clear();
+    if ( test_pegs.size() )
+        return &test_pegs[0];
 
     const PegInfo* p = Norm_GetPegs();
     assert(p);
 
     while ( p->name )
     {
-        pegs.push_back(*p);
-        pegs.push_back(createTestPeg(*p));
+        test_pegs.push_back(*p);
+        add_test_peg(*p);
         p++;
     }
 
@@ -400,13 +411,13 @@ const PegInfo* NormalizeModule::get_pegs() const
 
     while ( p->name )
     {
-        pegs.push_back(*p);
-        pegs.push_back(createTestPeg(*p));
+        test_pegs.push_back(*p);
+        add_test_peg(*p);
         p++;
     }
 
-    pegs.push_back(*p);
-    return &pegs[0];
+    test_pegs.push_back(*p);
+    return &test_pegs[0];
 }
 
 PegCount* NormalizeModule::get_counts() const
index d036b6729c5d36ff37521ba2a2da6e020db599b3..4daccd172304bb1a21339ca13da2e110b7be3fcc 100644 (file)
@@ -21,6 +21,9 @@
 #ifndef NORM_MODULE_H
 #define NORM_MODULE_H
 
+#include <string>
+#include <vector>
+
 #include "framework/module.h"
 #include "norm.h"
 
@@ -33,6 +36,7 @@ class NormalizeModule : public Module
 {
 public:
     NormalizeModule();
+    ~NormalizeModule();
 
     bool set(const char*, Value&, SnortConfig*) override;
     bool begin(const char*, int, SnortConfig*) override;
@@ -49,7 +53,12 @@ private:
     bool set_ip4(const char*, Value&, SnortConfig*);
     bool set_tcp(const char*, Value&, SnortConfig*);
 
+    void add_test_peg(const PegInfo&) const;
+
     NormalizerConfig config;
+
+    static std::vector<const std::string*> test_text;
+    static std::vector<PegInfo> test_pegs;
 };
 
 #endif