]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #1925 in SNORT/snort3 from ~MIALTIZE/snort3:f31_warnings to master
authorMichael Altizer (mialtize) <mialtize@cisco.com>
Wed, 8 Jan 2020 23:55:09 +0000 (23:55 +0000)
committerMichael Altizer (mialtize) <mialtize@cisco.com>
Wed, 8 Jan 2020 23:55:09 +0000 (23:55 +0000)
Squashed commit of the following:

commit f267210213b61f6beaf8c11ee14975da410db3bc
Author: Michael Altizer <mialtize@cisco.com>
Date:   Wed Jan 8 16:29:57 2020 -0500

    catch: Update to Catch v2.11.1

commit 12eb31c6584eb73e3b473ae65034f40d04367166
Author: Michael Altizer <mialtize@cisco.com>
Date:   Wed Jan 8 14:40:16 2020 -0500

    build: Fix more Clang 9 compiler warnings

14 files changed:
src/catch/catch.hpp
src/catch/unit_test.cc
src/detection/ips_context.cc
src/network_inspectors/appid/client_plugins/client_app_aim.cc
src/network_inspectors/reputation/reputation_parse.cc
src/piglet_plugins/pp_codec.cc
src/piglet_plugins/pp_inspector.cc
src/piglet_plugins/pp_ips_action.cc
src/piglet_plugins/pp_ips_option.cc
src/piglet_plugins/pp_logger.cc
src/piglet_plugins/pp_search_engine.cc
src/piglet_plugins/pp_so_rule.cc
src/piglet_plugins/pp_test.cc
src/profiler/rule_profiler.cc

index b4eccfc14834e36cbda131db9304cee15f1ae31d..6c1756a6cef5bf87eacb7aba0f3575bab2e1ae18 100644 (file)
@@ -1,6 +1,6 @@
 /*
- *  Catch v2.11.0
- *  Generated: 2019-11-15 15:01:56.628356
+ *  Catch v2.11.1
+ *  Generated: 2019-12-28 21:22:11.930976
  *  ----------------------------------------------------------
  *  This file has been merged from multiple headers. Please don't edit it directly
  *  Copyright (c) 2019 Two Blue Cubes Ltd. All rights reserved.
@@ -15,7 +15,7 @@
 
 #define CATCH_VERSION_MAJOR 2
 #define CATCH_VERSION_MINOR 11
-#define CATCH_VERSION_PATCH 0
+#define CATCH_VERSION_PATCH 1
 
 #ifdef __clang__
 #    pragma clang system_header
@@ -241,9 +241,12 @@ namespace Catch {
 // MSVC traditional preprocessor needs some workaround for __VA_ARGS__
 // _MSVC_TRADITIONAL == 0 means new conformant preprocessor
 // _MSVC_TRADITIONAL == 1 means old traditional non-conformant preprocessor
-#  if !defined(_MSVC_TRADITIONAL) || (defined(_MSVC_TRADITIONAL) && _MSVC_TRADITIONAL)
-#    define CATCH_INTERNAL_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
-#  endif
+#  if !defined(__clang__) // Handle Clang masquerading for msvc
+#    if !defined(_MSVC_TRADITIONAL) || (defined(_MSVC_TRADITIONAL) && _MSVC_TRADITIONAL)
+#      define CATCH_INTERNAL_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
+#    endif // MSVC_TRADITIONAL
+#  endif // __clang__
+
 #endif // _MSC_VER
 
 #if defined(_REENTRANT) || defined(_MSC_VER)
@@ -3907,7 +3910,6 @@ namespace Generators {
     class SingleValueGenerator final : public IGenerator<T> {
         T m_value;
     public:
-        SingleValueGenerator(T const& value) : m_value( value ) {}
         SingleValueGenerator(T&& value) : m_value(std::move(value)) {}
 
         T const& get() const override {
@@ -3970,21 +3972,21 @@ namespace Generators {
             m_generators.emplace_back(std::move(generator));
         }
         void populate(T&& val) {
-            m_generators.emplace_back(value(std::move(val)));
+            m_generators.emplace_back(value(std::forward<T>(val)));
         }
         template<typename U>
         void populate(U&& val) {
-            populate(T(std::move(val)));
+            populate(T(std::forward<U>(val)));
         }
         template<typename U, typename... Gs>
-        void populate(U&& valueOrGenerator, Gs... moreGenerators) {
+        void populate(U&& valueOrGenerator, Gs &&... moreGenerators) {
             populate(std::forward<U>(valueOrGenerator));
             populate(std::forward<Gs>(moreGenerators)...);
         }
 
     public:
         template <typename... Gs>
-        Generators(Gs... moreGenerators) {
+        Generators(Gs &&... moreGenerators) {
             m_generators.reserve(sizeof...(Gs));
             populate(std::forward<Gs>(moreGenerators)...);
         }
@@ -4015,7 +4017,7 @@ namespace Generators {
     struct as {};
 
     template<typename T, typename... Gs>
-    auto makeGenerators( GeneratorWrapper<T>&& generator, Gs... moreGenerators ) -> Generators<T> {
+    auto makeGenerators( GeneratorWrapper<T>&& generator, Gs &&... moreGenerators ) -> Generators<T> {
         return Generators<T>(std::move(generator), std::forward<Gs>(moreGenerators)...);
     }
     template<typename T>
@@ -4023,11 +4025,11 @@ namespace Generators {
         return Generators<T>(std::move(generator));
     }
     template<typename T, typename... Gs>
-    auto makeGenerators( T&& val, Gs... moreGenerators ) -> Generators<T> {
+    auto makeGenerators( T&& val, Gs &&... moreGenerators ) -> Generators<T> {
         return makeGenerators( value( std::forward<T>( val ) ), std::forward<Gs>( moreGenerators )... );
     }
     template<typename T, typename U, typename... Gs>
-    auto makeGenerators( as<T>, U&& val, Gs... moreGenerators ) -> Generators<T> {
+    auto makeGenerators( as<T>, U&& val, Gs &&... moreGenerators ) -> Generators<T> {
         return makeGenerators( value( T( std::forward<U>( val ) ) ), std::forward<Gs>( moreGenerators )... );
     }
 
@@ -4053,11 +4055,11 @@ namespace Generators {
 } // namespace Catch
 
 #define GENERATE( ... ) \
-    Catch::Generators::generate( CATCH_INTERNAL_LINEINFO, [ ]{ using namespace Catch::Generators; return makeGenerators( __VA_ARGS__ ); } )
+    Catch::Generators::generate( CATCH_INTERNAL_LINEINFO, [ ]{ using namespace Catch::Generators; return makeGenerators( __VA_ARGS__ ); } ) //NOLINT(google-build-using-namespace)
 #define GENERATE_COPY( ... ) \
-    Catch::Generators::generate( CATCH_INTERNAL_LINEINFO, [=]{ using namespace Catch::Generators; return makeGenerators( __VA_ARGS__ ); } )
+    Catch::Generators::generate( CATCH_INTERNAL_LINEINFO, [=]{ using namespace Catch::Generators; return makeGenerators( __VA_ARGS__ ); } ) //NOLINT(google-build-using-namespace)
 #define GENERATE_REF( ... ) \
-    Catch::Generators::generate( CATCH_INTERNAL_LINEINFO, [&]{ using namespace Catch::Generators; return makeGenerators( __VA_ARGS__ ); } )
+    Catch::Generators::generate( CATCH_INTERNAL_LINEINFO, [&]{ using namespace Catch::Generators; return makeGenerators( __VA_ARGS__ ); } ) //NOLINT(google-build-using-namespace)
 
 // end catch_generators.hpp
 // start catch_generators_generic.hpp
@@ -7320,60 +7322,65 @@ namespace Catch {
 #include <type_traits>
 
 namespace Catch {
-    namespace Detail {
-        template <typename T, bool Destruct>
-        struct ObjectStorage
-        {
-            using TStorage = typename std::aligned_storage<sizeof(T), std::alignment_of<T>::value>::type;
+    namespace Benchmark {
+        namespace Detail {
+            template <typename T, bool Destruct>
+            struct ObjectStorage
+            {
+                using TStorage = typename std::aligned_storage<sizeof(T), std::alignment_of<T>::value>::type;
 
-            ObjectStorage() : data() {}
+                ObjectStorage() : data() {}
 
-            ObjectStorage(const ObjectStorage& other)
-            {
-                new(&data) T(other.stored_object());
-            }
+                ObjectStorage(const ObjectStorage& other)
+                {
+                    new(&data) T(other.stored_object());
+                }
 
-            ObjectStorage(ObjectStorage&& other)
-            {
-                new(&data) T(std::move(other.stored_object()));
-            }
+                ObjectStorage(ObjectStorage&& other)
+                {
+                    new(&data) T(std::move(other.stored_object()));
+                }
 
-            ~ObjectStorage() { destruct_on_exit<T>(); }
+                ~ObjectStorage() { destruct_on_exit<T>(); }
 
-            template <typename... Args>
-            void construct(Args&&... args)
-            {
-                new (&data) T(std::forward<Args>(args)...);
-            }
+                template <typename... Args>
+                void construct(Args&&... args)
+                {
+                    new (&data) T(std::forward<Args>(args)...);
+                }
 
-            template <bool AllowManualDestruction = !Destruct>
-            typename std::enable_if<AllowManualDestruction>::type destruct()
-            {
-                stored_object().~T();
-            }
+                template <bool AllowManualDestruction = !Destruct>
+                typename std::enable_if<AllowManualDestruction>::type destruct()
+                {
+                    stored_object().~T();
+                }
 
-        private:
-            // If this is a constructor benchmark, destruct the underlying object
-            template <typename U>
-            void destruct_on_exit(typename std::enable_if<Destruct, U>::type* = 0) { destruct<true>(); }
-            // Otherwise, don't
-            template <typename U>
-            void destruct_on_exit(typename std::enable_if<!Destruct, U>::type* = 0) { }
-
-            T& stored_object()
-            {
-                return *static_cast<T*>(static_cast<void*>(&data));
-            }
+            private:
+                // If this is a constructor benchmark, destruct the underlying object
+                template <typename U>
+                void destruct_on_exit(typename std::enable_if<Destruct, U>::type* = 0) { destruct<true>(); }
+                // Otherwise, don't
+                template <typename U>
+                void destruct_on_exit(typename std::enable_if<!Destruct, U>::type* = 0) { }
+
+                T& stored_object() {
+                    return *static_cast<T*>(static_cast<void*>(&data));
+                }
 
-            TStorage data;
-        };
-    }
+                T const& stored_object() const {
+                    return *static_cast<T*>(static_cast<void*>(&data));
+                }
 
-    template <typename T>
-    using storage_for = Detail::ObjectStorage<T, true>;
+                TStorage data;
+            };
+        }
 
-    template <typename T>
-    using destructable_object = Detail::ObjectStorage<T, false>;
+        template <typename T>
+        using storage_for = Detail::ObjectStorage<T, true>;
+
+        template <typename T>
+        using destructable_object = Detail::ObjectStorage<T, false>;
+    }
 }
 
 // end catch_constructor.hpp
@@ -7854,6 +7861,17 @@ namespace Catch {
 
     #define CATCH_TRAP() __asm__("int $3\n" : : ) /* NOLINT */
 
+#elif defined(CATCH_PLATFORM_IPHONE)
+
+    // use inline assembler
+    #if defined(__i386__) || defined(__x86_64__)
+        #define CATCH_TRAP()  __asm__("int $3")
+    #elif defined(__aarch64__)
+        #define CATCH_TRAP()  __asm__(".inst 0xd4200000")
+    #elif defined(__arm__)
+        #define CATCH_TRAP()  __asm__(".inst 0xe7f001f0")
+    #endif
+
 #elif defined(CATCH_PLATFORM_LINUX)
     // If we can use inline assembler, do it because this allows us to break
     // directly at the location of the failing check instead of breaking inside
@@ -10094,7 +10112,7 @@ namespace {
 
     bool useColourOnPlatform() {
         return
-#ifdef CATCH_PLATFORM_MAC
+#if defined(CATCH_PLATFORM_MAC) || defined(CATCH_PLATFORM_IPHONE)
             !isDebuggerActive() &&
 #endif
 #if !(defined(__DJGPP__) && defined(__STRICT_ANSI__))
@@ -10271,7 +10289,7 @@ namespace Catch {
 // end catch_debug_console.cpp
 // start catch_debugger.cpp
 
-#ifdef CATCH_PLATFORM_MAC
+#if defined(CATCH_PLATFORM_MAC) || defined(CATCH_PLATFORM_IPHONE)
 
 #  include <assert.h>
 #  include <stdbool.h>
@@ -15050,7 +15068,7 @@ namespace Catch {
     }
 
     Version const& libraryVersion() {
-        static Version version( 2, 11, 0, "", 0 );
+        static Version version( 2, 11, 1, "", 0 );
         return version;
     }
 
index 9929443ed6dc0bda52125e21499011da3fefe837..b1a1924b4b357365137a85c7514a2bc344e12952 100644 (file)
@@ -65,7 +65,7 @@ int catch_test()
 // This isn't in snort_catch.cc because the linker may exclude the file if no static components
 // reference TestCaseInstaller
 SO_PUBLIC TestCaseInstaller::TestCaseInstaller(void(*fun)(), const char* name)
-{ REGISTER_TEST_CASE(fun, name); }
+{ REGISTER_TEST_CASE(fun, name) }
 
 SO_PUBLIC TestCaseInstaller::TestCaseInstaller(void(*fun)(), const char* name, const char* group)
-{ REGISTER_TEST_CASE(fun, name, group); }
+{ REGISTER_TEST_CASE(fun, name, group) }
index 15196214e4811205e6135475d221e68dff3c9bee..dc6f1883f325e4af71a360095e79348a148b6952 100644 (file)
@@ -181,8 +181,8 @@ TEST_CASE("IpsContext basic", "[IpsContext]")
     CHECK(TestData::count == num_data);
 }
 
-IpsContext* post_val;
-void test_post(IpsContext* c)
+static IpsContext* post_val;
+static void test_post(IpsContext* c)
 { post_val = c; }
 
 TEST_CASE("IpsContext post detection", "[IpsContext]")
index a8127410bed2b7514c30a8c63ad01a5ad3defcf3..0d439d6c8178a908429c837a6f3b9d0867ea62e9 100644 (file)
@@ -110,7 +110,6 @@ static inline bool check_username(
 {
     const uint8_t* const end = data + tlv->len;
     char* ptr = buf;
-    *buf_end = '\0';
 
     for ( const uint8_t* cur = data; cur < end; ++cur )
     {
@@ -123,6 +122,8 @@ static inline bool check_username(
             return false;
     }
 
+    *ptr = '\0';
+
     return true;
 }
 
@@ -196,7 +197,7 @@ int AimClientDetector::validate(AppIdDiscoveryArgs& args)
                         constexpr auto USERNAME_LEN = 256;
                         char username[USERNAME_LEN];
 
-                        if ( check_username(cur, tlv, username, username + USERNAME_LEN) )
+                        if ( check_username(cur, tlv, username, username + USERNAME_LEN - 1) )
                             add_user(args.asd, username, APP_ID_AOL_INSTANT_MESSENGER, true);
                     }
                     break;
index 8938f3c6777c7e61c590ebac68d5188a149d79f9..6a9dd5ade732f671b8add98ed20042cc82b00caa 100644 (file)
@@ -679,7 +679,7 @@ static void load_list_file(ListFile* list_info, ReputationConfig* config)
 static int num_lines_in_file(char* fname)
 {
     FILE* fp;
-    uint32_t numlines = 0;
+    int numlines = 0;
     char buf[MAX_ADDR_LINE_LENGTH];
 
     fp = fopen(fname, "rb");
index a7b01739132d6db7a4baffe6e36f62fbc8375274..bdff1c647a17c517a017a4c6b318d93dc10a726a 100644 (file)
@@ -46,9 +46,9 @@ private:
 };
 
 CodecPiglet::CodecPiglet(
-    Lua::State& state, const std::string& target, Module* m, SnortConfig* sc) :
-    BasePlugin(state, target, m, sc)
-{ wrapper = CodecManager::instantiate(target.c_str(), module, snort_conf); }
+    Lua::State& state, const std::string& tgt, Module* m, SnortConfig* sc) :
+    BasePlugin(state, tgt, m, sc)
+{ wrapper = CodecManager::instantiate(tgt.c_str(), module, snort_conf); }
 
 CodecPiglet::~CodecPiglet()
 {
index 21f75ca6f130efa1253ae0b1b200ee7e2cd6f675..5aa5f717038ed077e84e62ea757dcfd53c291547 100644 (file)
@@ -46,15 +46,15 @@ private:
 };
 
 InspectorPiglet::InspectorPiglet(
-    Lua::State& state, const std::string& target, Module* m, SnortConfig* sc) :
-    BasePlugin(state, target, m, sc)
+    Lua::State& state, const std::string& tgt, Module* m, SnortConfig* sc) :
+    BasePlugin(state, tgt, m, sc)
 {
     FlushBucket::set(0);
 
     assert(module);
     assert(snort_conf);
 
-    instance = InspectorManager::instantiate(target.c_str(), module, snort_conf);
+    instance = InspectorManager::instantiate(tgt.c_str(), module, snort_conf);
 }
 
 
index 7f5d34f7a55784b2be5021b05da1c8d340eaba0e..b97e3a8f84ab81b51a67cef9e2a7f51f9eaff9c0 100644 (file)
@@ -42,11 +42,11 @@ private:
 };
 
 IpsActionPiglet::IpsActionPiglet(
-    Lua::State& state, const std::string& target, Module* m, SnortConfig* sc) :
-    BasePlugin(state, target, m, sc)
+    Lua::State& state, const std::string& tgt, Module* m, SnortConfig* sc) :
+    BasePlugin(state, tgt, m, sc)
 {
     if ( module )
-        wrapper = ActionManager::instantiate(target.c_str(), m);
+        wrapper = ActionManager::instantiate(tgt.c_str(), m);
 }
 
 IpsActionPiglet::~IpsActionPiglet()
index eeb7c4592e6c852311dcc64b74d10dcf6947d9ea..012ffd37c37a9ee4434b9cf5206c138859fc19e8 100644 (file)
@@ -45,8 +45,8 @@ private:
 };
 
 IpsOptionPiglet::IpsOptionPiglet(
-    Lua::State& state, const std::string& target, Module* m) :
-    BasePlugin(state, target, m)
+    Lua::State& state, const std::string& tgt, Module* m) :
+    BasePlugin(state, tgt, m)
 {
     if ( !module )
         return;
@@ -56,7 +56,7 @@ IpsOptionPiglet::IpsOptionPiglet(
     if ( !otn )
         return;
 
-    wrapper = IpsManager::instantiate(target.c_str(), m, otn);
+    wrapper = IpsManager::instantiate(tgt.c_str(), m, otn);
 }
 
 IpsOptionPiglet::~IpsOptionPiglet()
index dfaa646d088d0877e6859607d1b27c95f0778a2b..69a320179cee9a307c3289b15c5c030efb07c30d 100644 (file)
@@ -45,12 +45,12 @@ private:
 };
 
 LoggerPiglet::LoggerPiglet(
-    Lua::State& state, const std::string& target, Module* m, SnortConfig* sc) :
-    BasePlugin(state, target, m, sc)
+    Lua::State& state, const std::string& tgt, Module* m, SnortConfig* sc) :
+    BasePlugin(state, tgt, m, sc)
 {
     // FIXIT-M does Logger need module?
     if ( module )
-        wrapper = EventManager::instantiate(target.c_str(), m, sc);
+        wrapper = EventManager::instantiate(tgt.c_str(), m, sc);
 }
 
 LoggerPiglet::~LoggerPiglet()
index af641d41ac8a4849b0d9c216efeb2d7a7159c3f4..503487b2e4cd3ca62490647ca7dd983e5e5c61b0 100644 (file)
@@ -40,9 +40,9 @@ private:
 };
 
 SearchEnginePiglet::SearchEnginePiglet(
-    Lua::State& state, const std::string& target, Module* m, SnortConfig* sc) :
-    BasePlugin(state, target, m, sc)
-{ wrapper = MpseManager::instantiate(target.c_str(), module, snort_conf); }
+    Lua::State& state, const std::string& tgt, Module* m, SnortConfig* sc) :
+    BasePlugin(state, tgt, m, sc)
+{ wrapper = MpseManager::instantiate(tgt.c_str(), module, snort_conf); }
 
 SearchEnginePiglet::~SearchEnginePiglet()
 {
index bcb3fa94b0eb8a642c40087e622bf2f0e73504bb..3386643cc3fc9a806a019ece655c8a4c1bc66ca2 100644 (file)
@@ -38,8 +38,8 @@ public:
 };
 
 SoRulePiglet::SoRulePiglet(
-    Lua::State& state, const std::string& target, Module* m, SnortConfig* sc) :
-    BasePlugin(state, target, m, sc) { }
+    Lua::State& state, const std::string& tgt, Module* m, SnortConfig* sc) :
+    BasePlugin(state, tgt, m, sc) { }
 
 
 bool SoRulePiglet::setup()
index dd1f06025896051c204318725260200d55d3fba1..fdd0c8df62ebec5c80b9858b4326e4cbb5446d1f 100644 (file)
@@ -40,8 +40,8 @@ using namespace snort;
 class TestPiglet : public Piglet::BasePlugin
 {
 public:
-    TestPiglet(Lua::State& state, const std::string& target) :
-        BasePlugin(state, target) { }
+    TestPiglet(Lua::State& state, const std::string& tgt) :
+        BasePlugin(state, tgt) { }
 
     bool setup() override;
 };
index 5012896dbe502ead6e57fa52fe76896c917eb869..52e415f874fd24f15503e3321bcb0ccac35b885e 100644 (file)
@@ -524,21 +524,21 @@ TEST_CASE( "rule entry", "[profiler][rule_profiler]" )
     SECTION( "avg_match" )
     {
         auto ticks = entry.avg_match();
-        INFO( ticks.count() << " == " << (1_ticks).count() );
+        INFO( ticks.count() << " == " << (1_ticks).count() )
         CHECK( (ticks == 1_ticks) );
     }
 
     SECTION( "avg_no_match" )
     {
         auto ticks = entry.avg_no_match();
-        INFO( ticks.count() << " == " << (1_ticks).count() );
+        INFO( ticks.count() << " == " << (1_ticks).count() )
         CHECK( (ticks == 1_ticks) );
     }
 
     SECTION( "avg_check" )
     {
         auto ticks = entry.avg_check();
-        INFO( ticks.count() << " == " << (1_ticks).count() );
+        INFO( ticks.count() << " == " << (1_ticks).count() )
         CHECK( (ticks == 1_ticks) );
     }
 }
@@ -697,10 +697,10 @@ TEST_CASE( "rule profiler time context", "[profiler][rule_profiler]" )
             avoid_optimization();
         }
 
-        INFO( "elapsed: " << stats.elapsed.count() );
+        INFO( "elapsed: " << stats.elapsed.count() )
         CHECK( (stats.elapsed > 0_ticks) );
         CHECK( stats.checks == 1 );
-        INFO( "elapsed_match: " << stats.elapsed_match.count() );
+        INFO( "elapsed_match: " << stats.elapsed_match.count() )
         CHECK( (stats.elapsed_match == 0_ticks) );
     }
 
@@ -715,7 +715,7 @@ TEST_CASE( "rule profiler time context", "[profiler][rule_profiler]" )
                 avoid_optimization();
                 ctx.stop(true);
 
-                INFO( "elapsed: " << stats.elapsed.count() );
+                INFO( "elapsed: " << stats.elapsed.count() )
                 CHECK( (stats.elapsed > 0_ticks) );
                 CHECK( stats.checks == 1 );
                 CHECK( stats.elapsed_match == stats.elapsed );
@@ -730,7 +730,7 @@ TEST_CASE( "rule profiler time context", "[profiler][rule_profiler]" )
                 avoid_optimization();
                 ctx.stop(false);
 
-                INFO( "elapsed: " << stats.elapsed.count() );
+                INFO( "elapsed: " << stats.elapsed.count() )
                 CHECK( (stats.elapsed > 0_ticks) );
                 CHECK( stats.checks == 1 );
                 CHECK( (stats.elapsed_match == 0_ticks) );
@@ -738,7 +738,7 @@ TEST_CASE( "rule profiler time context", "[profiler][rule_profiler]" )
             }
         }
 
-        INFO( "elapsed: " << stats.elapsed.count() );
+        INFO( "elapsed: " << stats.elapsed.count() )
         CHECK( stats.elapsed == save.elapsed );
         CHECK( stats.elapsed_match == save.elapsed_match );
         CHECK( stats.checks == save.checks );