From: Russ Combs (rucombs) Date: Mon, 20 Jun 2016 23:04:47 +0000 (-0400) Subject: Merge pull request #533 in SNORT/snort3 from ~MIALTIZE/snort3:icc to master X-Git-Tag: 3.0.0-233~356 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4d27d56cecfab956dcfbda900acd110bfe3df322;p=thirdparty%2Fsnort3.git Merge pull request #533 in SNORT/snort3 from ~MIALTIZE/snort3:icc to master Squashed commit of the following: commit 87abb8ece0c1d4c6df6e48ec009b11d77a8c777f Author: Michael Altizer Date: Mon Jun 20 12:45:45 2016 -0400 Clean up some ICC remarks. commit 5ed9ca766e264bca1fff2435121b1ee172ef160c Author: Michael Altizer Date: Sat Jun 18 10:15:12 2016 -0400 cmake: Remove unused FindCHECK.cmake commit 79eb7287f635f918fdc5845dc37b139220006d6d Author: Michael Altizer Date: Sat Jun 18 01:14:48 2016 -0400 unit-tests: Improve Catch behavior with ICC commit 69b9de9e9ba10f5633c3f4d93fa7e2526b38eb2f Author: Michael Altizer Date: Fri Jun 17 20:09:52 2016 -0400 unit-tests: Update Catch to v1.5.6 --- diff --git a/cmake/FindCHECK.cmake b/cmake/FindCHECK.cmake deleted file mode 100644 index 11da7497d..000000000 --- a/cmake/FindCHECK.cmake +++ /dev/null @@ -1,30 +0,0 @@ - - -set(ERROR_MESSAGE - "Unable to find libcheck!! Install libcheck before running - 'make check' command" -) - - -find_path (CHECK_INCLUDE_DIR - NAMES check.h -) - -find_library(CHECK_LIBRARIES - NAMES check -) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(CHECK - REQUIRED_VARS CHECK_INCLUDE_DIR CHECK_LIBRARIES - FAIL_MESSAGE "${ERROR_MESSAGE}" -) - - - -mark_as_advanced( - CHECK_INCLUDE_DIR - CHECK_LIBRARIES -) - - diff --git a/src/catch/catch.hpp b/src/catch/catch.hpp index 2a7146a7f..cde076dd2 100644 --- a/src/catch/catch.hpp +++ b/src/catch/catch.hpp @@ -1,6 +1,6 @@ /* - * Catch v1.4.0 - * Generated: 2016-03-15 07:23:12.623111 + * Catch v1.5.6 + * Generated: 2016-06-09 19:20:41.460328 * ---------------------------------------------------------- * This file has been merged from multiple headers. Please don't edit it directly * Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved. @@ -13,7 +13,9 @@ #define TWOBLUECUBES_CATCH_HPP_INCLUDED -#ifdef __clang__ +#ifdef __ICC +# pragma system_header +#elif __clang__ # pragma clang system_header #elif defined __GNUC__ # pragma GCC system_header @@ -21,22 +23,20 @@ // #included from: internal/catch_suppress_warnings.h -#ifdef __clang__ -# ifdef __ICC // icpc defines the __clang__ macro -# pragma warning(push) -# pragma warning(disable: 161 1682) -# else // __ICC -# pragma clang diagnostic ignored "-Wglobal-constructors" -# pragma clang diagnostic ignored "-Wvariadic-macros" -# pragma clang diagnostic ignored "-Wc99-extensions" -# pragma clang diagnostic ignored "-Wunused-variable" -# pragma clang diagnostic push -# pragma clang diagnostic ignored "-Wpadded" -# pragma clang diagnostic ignored "-Wc++98-compat" -# pragma clang diagnostic ignored "-Wc++98-compat-pedantic" -# pragma clang diagnostic ignored "-Wswitch-enum" -# pragma clang diagnostic ignored "-Wcovered-switch-default" -# endif +#ifdef __ICC +# pragma warning(push) +# pragma warning(disable: 161 1682) +#elif __clang__ +# pragma clang diagnostic ignored "-Wglobal-constructors" +# pragma clang diagnostic ignored "-Wvariadic-macros" +# pragma clang diagnostic ignored "-Wc99-extensions" +# pragma clang diagnostic ignored "-Wunused-variable" +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wpadded" +# pragma clang diagnostic ignored "-Wc++98-compat" +# pragma clang diagnostic ignored "-Wc++98-compat-pedantic" +# pragma clang diagnostic ignored "-Wswitch-enum" +# pragma clang diagnostic ignored "-Wcovered-switch-default" #elif defined __GNUC__ # pragma GCC diagnostic ignored "-Wvariadic-macros" # pragma GCC diagnostic ignored "-Wunused-variable" @@ -106,8 +106,16 @@ // All the C++11 features can be disabled with CATCH_CONFIG_NO_CPP11 -#if defined(__cplusplus) && __cplusplus >= 201103L -# define CATCH_CPP11_OR_GREATER +#ifdef __cplusplus + +# if __cplusplus >= 201103L +# define CATCH_CPP11_OR_GREATER +# endif + +# if __cplusplus >= 201402L +# define CATCH_CPP14_OR_GREATER +# endif + #endif #ifdef __clang__ @@ -2065,7 +2073,7 @@ namespace Catch { __catchResult.useActiveException( Catch::ResultDisposition::Normal ); \ } \ INTERNAL_CATCH_REACT( __catchResult ) \ - } while( Catch::isTrue( false && static_cast(expr) ) ) // expr here is never evaluated at runtime but it forces the compiler to give it a look + } while( Catch::isTrue( false && !!(expr) ) ) // expr here is never evaluated at runtime but it forces the compiler to give it a look /////////////////////////////////////////////////////////////////////////////// #define INTERNAL_CATCH_IF( expr, resultDisposition, macroName ) \ @@ -3450,7 +3458,7 @@ namespace Catch { }; class DebugOutStream : public IStream { - std::auto_ptr m_streamBuf; + CATCH_AUTO_PTR( StreamBufBase ) m_streamBuf; mutable std::ostream m_os; public: DebugOutStream(); @@ -3598,7 +3606,7 @@ namespace Catch { } ConfigData m_data; - std::auto_ptr m_stream; + CATCH_AUTO_PTR( IStream const ) m_stream; TestSpec m_testSpec; }; @@ -3618,7 +3626,7 @@ namespace Catch { #define STITCH_CLARA_OPEN_NAMESPACE namespace Catch { // #included from: ../external/clara.h -// Version 0.0.1.1 +// Version 0.0.2.4 // Only use header guard if we are not using an outer namespace #if !defined(TWOBLUECUBES_CLARA_H_INCLUDED) || defined(STITCH_CLARA_OPEN_NAMESPACE) @@ -3934,6 +3942,10 @@ namespace Tbc { #include #include +#if defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER) +#define CLARA_PLATFORM_WINDOWS +#endif + // Use optional outer namespace #ifdef STITCH_CLARA_OPEN_NAMESPACE STITCH_CLARA_OPEN_NAMESPACE @@ -3957,9 +3969,6 @@ namespace Clara { const unsigned int consoleWidth = 80; #endif - // Use this to try and stop compiler from warning about unreachable code - inline bool isTrue( bool value ) { return value; } - using namespace Tbc; inline bool startsWith( std::string const& str, std::string const& prefix ) { @@ -3995,14 +4004,6 @@ namespace Clara { else throw std::runtime_error( "Expected a boolean value but did not recognise:\n '" + _source + "'" ); } - inline void convertInto( bool _source, bool& _dest ) { - _dest = _source; - } - template - inline void convertInto( bool, T& ) { - if( isTrue( true ) ) - throw std::runtime_error( "Invalid conversion" ); - } template struct IArgFunction { @@ -4012,7 +4013,6 @@ namespace Clara { IArgFunction( IArgFunction const& ) = default; #endif virtual void set( ConfigT& config, std::string const& value ) const = 0; - virtual void setFlag( ConfigT& config ) const = 0; virtual bool takesArg() const = 0; virtual IArgFunction* clone() const = 0; }; @@ -4034,9 +4034,6 @@ namespace Clara { void set( ConfigT& config, std::string const& value ) const { functionObj->set( config, value ); } - void setFlag( ConfigT& config ) const { - functionObj->setFlag( config ); - } bool takesArg() const { return functionObj->takesArg(); } bool isSet() const { @@ -4049,7 +4046,6 @@ namespace Clara { template struct NullBinder : IArgFunction{ virtual void set( C&, std::string const& ) const {} - virtual void setFlag( C& ) const {} virtual bool takesArg() const { return true; } virtual IArgFunction* clone() const { return new NullBinder( *this ); } }; @@ -4060,9 +4056,6 @@ namespace Clara { virtual void set( C& p, std::string const& stringValue ) const { convertInto( stringValue, p.*member ); } - virtual void setFlag( C& p ) const { - convertInto( true, p.*member ); - } virtual bool takesArg() const { return !IsBool::value; } virtual IArgFunction* clone() const { return new BoundDataMember( *this ); } M C::* member; @@ -4075,11 +4068,6 @@ namespace Clara { convertInto( stringValue, value ); (p.*member)( value ); } - virtual void setFlag( C& p ) const { - typename RemoveConstRef::type value; - convertInto( true, value ); - (p.*member)( value ); - } virtual bool takesArg() const { return !IsBool::value; } virtual IArgFunction* clone() const { return new BoundUnaryMethod( *this ); } void (C::*member)( M ); @@ -4093,9 +4081,6 @@ namespace Clara { if( value ) (p.*member)(); } - virtual void setFlag( C& p ) const { - (p.*member)(); - } virtual bool takesArg() const { return false; } virtual IArgFunction* clone() const { return new BoundNullaryMethod( *this ); } void (C::*member)(); @@ -4110,9 +4095,6 @@ namespace Clara { if( value ) function( obj ); } - virtual void setFlag( C& p ) const { - function( p ); - } virtual bool takesArg() const { return false; } virtual IArgFunction* clone() const { return new BoundUnaryFunction( *this ); } void (*function)( C& ); @@ -4126,11 +4108,6 @@ namespace Clara { convertInto( stringValue, value ); function( obj, value ); } - virtual void setFlag( C& obj ) const { - typename RemoveConstRef::type value; - convertInto( true, value ); - function( obj, value ); - } virtual bool takesArg() const { return !IsBool::value; } virtual IArgFunction* clone() const { return new BoundBinaryFunction( *this ); } void (*function)( C&, T ); @@ -4138,8 +4115,20 @@ namespace Clara { } // namespace Detail - struct Parser { - Parser() : separators( " \t=:" ) {} + inline std::vector argsToVector( int argc, char const* const* const argv ) { + std::vector args( static_cast( argc ) ); + for( std::size_t i = 0; i < static_cast( argc ); ++i ) + args[i] = argv[i]; + + return args; + } + + class Parser { + enum Mode { None, MaybeShortOpt, SlashOpt, ShortOpt, LongOpt, Positional }; + Mode mode; + std::size_t from; + bool inQuotes; + public: struct Token { enum Type { Positional, ShortOpt, LongOpt }; @@ -4148,38 +4137,75 @@ namespace Clara { std::string data; }; - void parseIntoTokens( int argc, char const* const argv[], std::vector& tokens ) const { + Parser() : mode( None ), from( 0 ), inQuotes( false ){} + + void parseIntoTokens( std::vector const& args, std::vector& tokens ) { const std::string doubleDash = "--"; - for( int i = 1; i < argc && argv[i] != doubleDash; ++i ) - parseIntoTokens( argv[i] , tokens); - } - void parseIntoTokens( std::string arg, std::vector& tokens ) const { - while( !arg.empty() ) { - Parser::Token token( Parser::Token::Positional, arg ); - arg = ""; - if( token.data[0] == '-' ) { - if( token.data.size() > 1 && token.data[1] == '-' ) { - token = Parser::Token( Parser::Token::LongOpt, token.data.substr( 2 ) ); - } - else { - token = Parser::Token( Parser::Token::ShortOpt, token.data.substr( 1 ) ); - if( token.data.size() > 1 && separators.find( token.data[1] ) == std::string::npos ) { - arg = "-" + token.data.substr( 1 ); - token.data = token.data.substr( 0, 1 ); - } - } - } - if( token.type != Parser::Token::Positional ) { - std::size_t pos = token.data.find_first_of( separators ); - if( pos != std::string::npos ) { - arg = token.data.substr( pos+1 ); - token.data = token.data.substr( 0, pos ); - } - } - tokens.push_back( token ); + for( std::size_t i = 1; i < args.size() && args[i] != doubleDash; ++i ) + parseIntoTokens( args[i], tokens); + } + + void parseIntoTokens( std::string const& arg, std::vector& tokens ) { + for( std::size_t i = 0; i <= arg.size(); ++i ) { + char c = arg[i]; + if( c == '"' ) + inQuotes = !inQuotes; + mode = handleMode( i, c, arg, tokens ); } } - std::string separators; + Mode handleMode( std::size_t i, char c, std::string const& arg, std::vector& tokens ) { + switch( mode ) { + case None: return handleNone( i, c ); + case MaybeShortOpt: return handleMaybeShortOpt( i, c ); + case ShortOpt: + case LongOpt: + case SlashOpt: return handleOpt( i, c, arg, tokens ); + case Positional: return handlePositional( i, c, arg, tokens ); + default: throw std::logic_error( "Unknown mode" ); + } + } + + Mode handleNone( std::size_t i, char c ) { + if( inQuotes ) { + from = i; + return Positional; + } + switch( c ) { + case '-': return MaybeShortOpt; +#ifdef CLARA_PLATFORM_WINDOWS + case '/': from = i+1; return SlashOpt; +#endif + default: from = i; return Positional; + } + } + Mode handleMaybeShortOpt( std::size_t i, char c ) { + switch( c ) { + case '-': from = i+1; return LongOpt; + default: from = i; return ShortOpt; + } + } + Mode handleOpt( std::size_t i, char c, std::string const& arg, std::vector& tokens ) { + if( std::string( ":=\0", 3 ).find( c ) == std::string::npos ) + return mode; + + std::string optName = arg.substr( from, i-from ); + if( mode == ShortOpt ) + for( std::size_t j = 0; j < optName.size(); ++j ) + tokens.push_back( Token( Token::ShortOpt, optName.substr( j, 1 ) ) ); + else if( mode == SlashOpt && optName.size() == 1 ) + tokens.push_back( Token( Token::ShortOpt, optName ) ); + else + tokens.push_back( Token( Token::LongOpt, optName ) ); + return None; + } + Mode handlePositional( std::size_t i, char c, std::string const& arg, std::vector& tokens ) { + if( inQuotes || std::string( "\0", 1 ).find( c ) == std::string::npos ) + return mode; + + std::string data = arg.substr( from, i-from ); + tokens.push_back( Token( Token::Positional, data ) ); + return None; + } }; template @@ -4482,21 +4508,21 @@ namespace Clara { return oss.str(); } - ConfigT parse( int argc, char const* const argv[] ) const { + ConfigT parse( std::vector const& args ) const { ConfigT config; - parseInto( argc, argv, config ); + parseInto( args, config ); return config; } - std::vector parseInto( int argc, char const* argv[], ConfigT& config ) const { - std::string processName = argv[0]; + std::vector parseInto( std::vector const& args, ConfigT& config ) const { + std::string processName = args[0]; std::size_t lastSlash = processName.find_last_of( "/\\" ); if( lastSlash != std::string::npos ) processName = processName.substr( lastSlash+1 ); m_boundProcessName.set( config, processName ); std::vector tokens; Parser parser; - parser.parseIntoTokens( argc, argv, tokens ); + parser.parseIntoTokens( args, tokens ); return populate( tokens, config ); } @@ -4527,7 +4553,7 @@ namespace Clara { arg.boundField.set( config, tokens[++i].data ); } else { - arg.boundField.setFlag( config ); + arg.boundField.set( config, "true" ); } break; } @@ -5235,6 +5261,8 @@ namespace Catch bool aborting; }; + class MultipleReporters; + struct IStreamingReporter : IShared { virtual ~IStreamingReporter(); @@ -5262,6 +5290,8 @@ namespace Catch virtual void testRunEnded( TestRunStats const& testRunStats ) = 0; virtual void skipTest( TestCaseInfo const& testInfo ) = 0; + + virtual MultipleReporters* tryAsMulti() { return CATCH_NULL; } }; struct IReporterFactory : IShared { @@ -5479,6 +5509,10 @@ namespace TestCaseTracking { virtual void addChild( Ptr const& child ) = 0; virtual ITracker* findChild( std::string const& name ) = 0; virtual void openChild() = 0; + + // Debug/ checking + virtual bool isSectionTracker() const = 0; + virtual bool isIndexTracker() const = 0; }; class TrackerContext { @@ -5603,6 +5637,10 @@ namespace TestCaseTracking { m_parent->openChild(); } } + + virtual bool isSectionTracker() const CATCH_OVERRIDE { return false; } + virtual bool isIndexTracker() const CATCH_OVERRIDE { return false; } + void open() { m_runState = Executing; moveToThis(); @@ -5666,13 +5704,16 @@ namespace TestCaseTracking { {} virtual ~SectionTracker(); + virtual bool isSectionTracker() const CATCH_OVERRIDE { return true; } + static SectionTracker& acquire( TrackerContext& ctx, std::string const& name ) { SectionTracker* section = CATCH_NULL; ITracker& currentTracker = ctx.currentTracker(); if( ITracker* childTracker = currentTracker.findChild( name ) ) { - section = dynamic_cast( childTracker ); - assert( section ); + assert( childTracker ); + assert( childTracker->isSectionTracker() ); + section = static_cast( childTracker ); } else { section = new SectionTracker( name, ctx, ¤tTracker ); @@ -5697,13 +5738,16 @@ namespace TestCaseTracking { {} virtual ~IndexTracker(); + virtual bool isIndexTracker() const CATCH_OVERRIDE { return true; } + static IndexTracker& acquire( TrackerContext& ctx, std::string const& name, int size ) { IndexTracker* tracker = CATCH_NULL; ITracker& currentTracker = ctx.currentTracker(); if( ITracker* childTracker = currentTracker.findChild( name ) ) { - tracker = dynamic_cast( childTracker ); - assert( tracker ); + assert( childTracker ); + assert( childTracker->isIndexTracker() ); + tracker = static_cast( childTracker ); } else { tracker = new IndexTracker( name, ctx, ¤tTracker, size ); @@ -6306,10 +6350,10 @@ namespace Catch { Catch::cout() << "For more detail usage please see the project docs\n" << std::endl; } - int applyCommandLine( int argc, char const* argv[], OnUnusedOptions::DoWhat unusedOptionBehaviour = OnUnusedOptions::Fail ) { + int applyCommandLine( int argc, char const* const* const argv, OnUnusedOptions::DoWhat unusedOptionBehaviour = OnUnusedOptions::Fail ) { try { m_cli.setThrowOnUnrecognisedTokens( unusedOptionBehaviour == OnUnusedOptions::Fail ); - m_unusedTokens = m_cli.parseInto( argc, argv, m_configData ); + m_unusedTokens = m_cli.parseInto( Clara::argsToVector( argc, argv ), m_configData ); if( m_configData.showHelp ) showHelp( m_configData.processName ); m_config.reset(); @@ -6333,16 +6377,13 @@ namespace Catch { m_config.reset(); } - int run( int argc, char const* argv[] ) { + int run( int argc, char const* const* const argv ) { int returnCode = applyCommandLine( argc, argv ); if( returnCode == 0 ) returnCode = run(); return returnCode; } - int run( int argc, char* argv[] ) { - return run( argc, const_cast( argv ) ); - } int run() { if( m_configData.showHelp ) @@ -6406,13 +6447,31 @@ namespace Catch { #include #include +#ifdef CATCH_CPP14_OR_GREATER +#include +#endif + namespace Catch { - struct LexSort { - bool operator() (TestCase i,TestCase j) const { return (i + static void shuffle( V& vector ) { + RandomNumberGenerator rng; +#ifdef CATCH_CPP14_OR_GREATER + std::shuffle( vector.begin(), vector.end(), rng ); +#else + std::random_shuffle( vector.begin(), vector.end(), rng ); +#endif + } }; inline std::vector sortTests( IConfig const& config, std::vector const& unsortedTestCases ) { @@ -6421,14 +6480,12 @@ namespace Catch { switch( config.runOrder() ) { case RunTests::InLexicographicalOrder: - std::sort( sorted.begin(), sorted.end(), LexSort() ); + std::sort( sorted.begin(), sorted.end() ); break; case RunTests::InRandomOrder: { seedRng( config ); - - RandomNumberGenerator rng; - std::random_shuffle( sorted.begin(), sorted.end(), rng ); + RandomNumberGenerator::shuffle( sorted ); } break; case RunTests::InDeclarationOrder: @@ -6447,13 +6504,15 @@ namespace Catch { it != itEnd; ++it ) { std::pair::const_iterator, bool> prev = seenFunctions.insert( *it ); - if( !prev.second ){ - Catch::cerr() - << Colour( Colour::Red ) - << "error: TEST_CASE( \"" << it->name << "\" ) already defined.\n" - << "\tFirst seen at " << prev.first->getTestCaseInfo().lineInfo << "\n" - << "\tRedefined at " << it->getTestCaseInfo().lineInfo << std::endl; - exit(1); + if( !prev.second ) { + std::ostringstream ss; + + ss << Colour( Colour::Red ) + << "error: TEST_CASE( \"" << it->name << "\" ) already defined.\n" + << "\tFirst seen at " << prev.first->getTestCaseInfo().lineInfo << "\n" + << "\tRedefined at " << it->getTestCaseInfo().lineInfo << std::endl; + + throw std::runtime_error(ss.str()); } } } @@ -7512,7 +7571,7 @@ namespace Catch { return os; } - Version libraryVersion( 1, 4, 0, "", 0 ); + Version libraryVersion( 1, 5, 6, "", 0 ); } @@ -8491,13 +8550,18 @@ public: // IStreamingReporter ++it ) (*it)->skipTest( testInfo ); } + + virtual MultipleReporters* tryAsMulti() CATCH_OVERRIDE { + return this; + } + }; Ptr addReporter( Ptr const& existingReporter, Ptr const& additionalReporter ) { Ptr resultingReporter; if( existingReporter ) { - MultipleReporters* multi = dynamic_cast( existingReporter.get() ); + MultipleReporters* multi = existingReporter->tryAsMulti(); if( !multi ) { multi = new MultipleReporters; resultingReporter = Ptr( multi ); @@ -8677,7 +8741,7 @@ namespace Catch { virtual void assertionStarting( AssertionInfo const& ) CATCH_OVERRIDE {} - virtual bool assertionEnded( AssertionStats const& assertionStats ) { + virtual bool assertionEnded( AssertionStats const& assertionStats ) CATCH_OVERRIDE { assert( !m_sectionStack.empty() ); SectionNode& sectionNode = *m_sectionStack.back(); sectionNode.assertions.push_back( assertionStats ); @@ -9068,12 +9132,10 @@ namespace Catch { #define TWOBLUECUBES_CATCH_REENABLE_WARNINGS_H_INCLUDED -#ifdef __clang__ -# ifdef __ICC // icpc defines the __clang__ macro -# pragma warning(pop) -# else -# pragma clang diagnostic pop -# endif +#ifdef __ICC +# pragma warning(pop) +#elif __clang__ +# pragma clang diagnostic pop #elif defined __GNUC__ # pragma GCC diagnostic pop #endif diff --git a/src/codecs/ip/cd_ipv4.cc b/src/codecs/ip/cd_ipv4.cc index 1c4776728..5bbf623d8 100644 --- a/src/codecs/ip/cd_ipv4.cc +++ b/src/codecs/ip/cd_ipv4.cc @@ -188,7 +188,7 @@ bool Ipv4Codec::decode(const RawData& raw, CodecData& codec, DecodeData& snort) if (ip_len > raw.len) { DebugFormat(DEBUG_DECODE, - "IP Len field is %d bytes bigger than captured length.\n" + "IP Len field is %u bytes bigger than captured length.\n" " (ip.len: %u, cap.len: %u)\n", ip_len - raw.len, ip_len, raw.len); @@ -207,8 +207,8 @@ bool Ipv4Codec::decode(const RawData& raw, CodecData& codec, DecodeData& snort) if (ip_len < hlen) { DebugFormat(DEBUG_DECODE, - "IP dgm len (%d bytes) < IP hdr " - "len (%d bytes), packet discarded\n", ip_len, hlen); + "IP dgm len (%u bytes) < IP hdr " + "len (%hu bytes), packet discarded\n", ip_len, hlen); codec_event(codec, DECODE_IPV4_DGRAM_LT_IPHDR); return false; diff --git a/src/codecs/misc/cd_gtp.cc b/src/codecs/misc/cd_gtp.cc index f4e1ad2ba..d119daaa7 100644 --- a/src/codecs/misc/cd_gtp.cc +++ b/src/codecs/misc/cd_gtp.cc @@ -119,7 +119,7 @@ bool GtpCodec::decode(const RawData& raw, CodecData& codec, DecodeData& dd) if (raw.len != ((unsigned int)ntohs(hdr->length) + len)) { - DebugFormat(DEBUG_DECODE, "Calculated length %d != %d in header.\n", + DebugFormat(DEBUG_DECODE, "Calculated length %u != %hu in header.\n", raw.len - len, ntohs(hdr->length)); codec_event(codec, DECODE_GTP_BAD_LEN); return false; @@ -175,7 +175,7 @@ bool GtpCodec::decode(const RawData& raw, CodecData& codec, DecodeData& dd) if (raw.len != ((unsigned int)ntohs(hdr->length) + GTP_MIN_LEN)) { - DebugFormat(DEBUG_DECODE, "Calculated length %d != %d in header.\n", + DebugFormat(DEBUG_DECODE, "Calculated length %u != %hu in header.\n", raw.len - GTP_MIN_LEN, ntohs(hdr->length)); codec_event(codec, DECODE_GTP_BAD_LEN); return false; diff --git a/src/detection/detection_options.cc b/src/detection/detection_options.cc index 59b5edc93..9a027914c 100644 --- a/src/detection/detection_options.cc +++ b/src/detection/detection_options.cc @@ -432,7 +432,7 @@ int detection_option_node_evaluate( { // none of the services match DebugFormat(DEBUG_DETECT, - "[**] SID %d not matched because of service mismatch (%d!=%d [**]\n", + "[**] SID %u not matched because of service mismatch (%d!=%d [**]\n", sig_info.id, app_proto, sig_info.services[0].service_ordinal); break; // out of case diff --git a/src/detection/tag.cc b/src/detection/tag.cc index 5c6042d9f..e7217c795 100644 --- a/src/detection/tag.cc +++ b/src/detection/tag.cc @@ -473,7 +473,7 @@ int CheckTagList(Packet* p, Event* event, void** log_list) return 0; } - DebugFormat(DEBUG_FLOW,"Host Tags Active: %d Session Tags Active: %d\n", + DebugFormat(DEBUG_FLOW,"Host Tags Active: %u Session Tags Active: %u\n", sfxhash_count(host_tag_cache_ptr), sfxhash_count(ssn_tag_cache_ptr)); DebugMessage(DEBUG_FLOW, "[*] Checking session tag list (forward)...\n"); diff --git a/src/file_api/file_log.cc b/src/file_api/file_log.cc index 5aff718cd..746b968be 100644 --- a/src/file_api/file_log.cc +++ b/src/file_api/file_log.cc @@ -201,7 +201,7 @@ public: FileLog(FileLogConfig& conf) { config = conf; } void show(SnortConfig*) override; - void eval(Packet*) override { }; + void eval(Packet*) override { } bool configure(SnortConfig*) override { diff --git a/src/filters/sfrf_test.cc b/src/filters/sfrf_test.cc index d58dd7f3e..8f7427f5a 100644 --- a/src/filters/sfrf_test.cc +++ b/src/filters/sfrf_test.cc @@ -975,7 +975,7 @@ static int EventCheck(int i) if ( p->expect == status ) return 1; - printf("event[%d](%d,%d): exp %d, got %d\n", + printf("event[%u](%u,%u): exp %d, got %d\n", p->seq, p->gid, p->sid, p->expect, status); return 0; } @@ -988,7 +988,7 @@ static int CapCheck(int i) if ( RULE_ORIG == status ) return 1; - printf("cap[%d](%d,%d): exp %d, got %d\n", + printf("cap[%u](%u,%u): exp %d, got %d\n", p->seq, p->gid, p->sid, RULE_ORIG, status); return 0; } diff --git a/src/filters/sfthd_test.cc b/src/filters/sfthd_test.cc index 2bdb84ea7..6c2f404df 100644 --- a/src/filters/sfthd_test.cc +++ b/src/filters/sfthd_test.cc @@ -843,7 +843,7 @@ static int EventCheck(int i) if ( p->expect == status ) return 1; - printf("event[%d](%d,%d): exp %d, got %d\n", + printf("event[%u](%u,%u): exp %d, got %d\n", p->seq, p->gid, p->sid, p->expect, status); return 0; } @@ -871,7 +871,7 @@ static int CapCheck(int i) if ( expect == status ) return 1; - printf("cap[%d](%d,%d): exp %d, got %d\n", + printf("cap[%u](%u,%u): exp %d, got %d\n", p->seq, p->gid, p->sid, expect, status); return 0; } @@ -885,7 +885,7 @@ static int PacketCheck(int i) if ( p->expect == status ) return 1; - printf("packet[%d](%d,%d): exp %d, got %d\n", + printf("packet[%u](%u,%u): exp %d, got %d\n", p->seq, p->gid, p->sid, p->expect, status); return 0; } diff --git a/src/flow/ha.cc b/src/flow/ha.cc index 6714ab68c..eabff397f 100644 --- a/src/flow/ha.cc +++ b/src/flow/ha.cc @@ -468,7 +468,7 @@ void HighAvailability::receive_handler(SCMessage* sc_msg) { assert(sc_msg); - DebugFormat(DEBUG_HA,"HighAvailability::receive_handler: port: %d, length: %d\n", + DebugFormat(DEBUG_HA,"HighAvailability::receive_handler: port: %hu, length: %u\n", sc_msg->hdr->port, sc_msg->content_length); // SC received messages must have reference back to SideChannel object diff --git a/src/helpers/chunk.cc b/src/helpers/chunk.cc index f95af86c1..e37b69d19 100644 --- a/src/helpers/chunk.cc +++ b/src/helpers/chunk.cc @@ -88,7 +88,6 @@ bool init_chunk( TEST_CASE( "chunk initialization", "[chunk]" ) { Lua::State lua(true); - bool result; string test_chunk = "function init() return true end"; string test_args_table = "args = { a = 1, b = 2 }"; diff --git a/src/ips_options/ips_flowbits.cc b/src/ips_options/ips_flowbits.cc index cdd8093e4..5949c7557 100644 --- a/src/ips_options/ips_flowbits.cc +++ b/src/ips_options/ips_flowbits.cc @@ -826,7 +826,7 @@ static void printOutFlowbits(FLOWBITS_OP* flowbits) DebugFormat(DEBUG_FLOWBITS, "%s: name = %s\n", s_name, flowbits->name); DebugFormat(DEBUG_FLOWBITS, "%s: eval = %d\n", s_name, flowbits->eval); DebugFormat(DEBUG_FLOWBITS, "%s: num_ids = %d\n", s_name, flowbits->num_ids); - DebugFormat(DEBUG_FLOWBITS, "%s: grp_id = %d\n", s_name, flowbits->group_id); + DebugFormat(DEBUG_FLOWBITS, "%s: grp_id = %u\n", s_name, flowbits->group_id); DebugFormat(DEBUG_FLOWBITS, "%s: group_name = %s\n", s_name, flowbits->group); for (int i = 0; i < flowbits->num_ids; i++) diff --git a/src/latency/packet_latency.cc b/src/latency/packet_latency.cc index c39d422bd..2e7f4087e 100644 --- a/src/latency/packet_latency.cc +++ b/src/latency/packet_latency.cc @@ -268,7 +268,7 @@ void PacketLatency::tterm() namespace t_packet_latency { -struct MockConfigWrapper : packet_latency::ConfigWrapper +struct MockConfigWrapper : public packet_latency::ConfigWrapper { PacketLatencyConfig config; @@ -276,14 +276,14 @@ struct MockConfigWrapper : packet_latency::ConfigWrapper { return &config; } }; -struct EventHandlerSpy : packet_latency::EventHandler +struct EventHandlerSpy : public packet_latency::EventHandler { unsigned count = 0; void handle(const packet_latency::Event&) override { ++count; } }; -struct MockClock : ClockTraits +struct MockClock : public ClockTraits { static hr_time t; diff --git a/src/latency/rule_latency.cc b/src/latency/rule_latency.cc index 358f536b3..3cdc883c6 100644 --- a/src/latency/rule_latency.cc +++ b/src/latency/rule_latency.cc @@ -381,7 +381,7 @@ void RuleLatency::tterm() namespace t_rule_latency { -struct MockConfigWrapper : rule_latency::ConfigWrapper +struct MockConfigWrapper : public rule_latency::ConfigWrapper { RuleLatencyConfig config; @@ -389,14 +389,14 @@ struct MockConfigWrapper : rule_latency::ConfigWrapper { return &config; } }; -struct EventHandlerSpy : rule_latency::EventHandler +struct EventHandlerSpy : public rule_latency::EventHandler { unsigned count = 0; void handle(const rule_latency::Event&) override { ++count; } }; -struct MockClock : ClockTraits +struct MockClock : public ClockTraits { static hr_time t; diff --git a/src/managers/ips_manager.cc b/src/managers/ips_manager.cc index 07cb9753b..c026b8bf0 100644 --- a/src/managers/ips_manager.cc +++ b/src/managers/ips_manager.cc @@ -192,7 +192,7 @@ bool IpsManager::option_begin( if ( opt->api->max_per_rule && (++opt->count > opt->api->max_per_rule) ) { - ParseError("%s allowed only %d time(s) per rule", + ParseError("%s allowed only %u time(s) per rule", opt->api->base.name, opt->api->max_per_rule); return false; } diff --git a/src/network_inspectors/packet_capture/packet_capture.cc b/src/network_inspectors/packet_capture/packet_capture.cc index 9062b4004..23b058680 100644 --- a/src/network_inspectors/packet_capture/packet_capture.cc +++ b/src/network_inspectors/packet_capture/packet_capture.cc @@ -221,7 +221,7 @@ const BaseApi* nin_packet_capture = &pc_api.base; #endif #ifdef UNIT_TEST -Packet* init_null_packet() +static Packet* init_null_packet() { static Packet p(false); static DAQ_PktHdr_t h; @@ -317,7 +317,6 @@ TEST_CASE("blank filter", "[PacketCapture]") auto null_packet = init_null_packet(); const uint8_t cooked[] = "AbCdEfGhIjKlMnOpQrStUvWxYz"; - struct pcap_pkthdr hdr; Packet p(false); DAQ_PktHdr_t daq_hdr; diff --git a/src/network_inspectors/port_scan/port_scan.cc b/src/network_inspectors/port_scan/port_scan.cc index c842e1629..28e0b793d 100644 --- a/src/network_inspectors/port_scan/port_scan.cc +++ b/src/network_inspectors/port_scan/port_scan.cc @@ -309,7 +309,7 @@ static int MakeOpenPortInfo( return -1; SnortSnprintf((char*)buffer, PROTO_BUFFER_SIZE, - "Open Port: %u\n", *((unsigned short*)user)); + "Open Port: %hu\n", *((unsigned short*)user)); dsize = SnortStrnlen((const char*)buffer, PROTO_BUFFER_SIZE); *total_size += dsize; diff --git a/src/network_inspectors/reputation/reputation_parse.cc b/src/network_inspectors/reputation/reputation_parse.cc index e9d45ffc4..b52a313c2 100644 --- a/src/network_inspectors/reputation/reputation_parse.cc +++ b/src/network_inspectors/reputation/reputation_parse.cc @@ -354,9 +354,9 @@ static int AddIPtoList(sfip_t* ipAddr,INFO ipInfo_ptr, ReputationConfig* config) { #ifdef DEBUG_MSGS IPrepInfo* result; - DebugFormat(DEBUG_REPUTATION, "Number of entries input: %d, in table: %d \n", + DebugFormat(DEBUG_REPUTATION, "Number of entries input: %d, in table: %u \n", totalNumEntries,sfrt_flat_num_entries(config->iplist) ); - DebugFormat(DEBUG_REPUTATION, "Memory allocated: %d \n",sfrt_flat_usage(config->iplist) ); + DebugFormat(DEBUG_REPUTATION, "Memory allocated: %u \n",sfrt_flat_usage(config->iplist) ); result = (IPrepInfo*)sfrt_flat_lookup((void*)ipAddr, config->iplist); if (nullptr != result) { diff --git a/src/parser/parser.cc b/src/parser/parser.cc index 849f961d3..a10095eaa 100644 --- a/src/parser/parser.cc +++ b/src/parser/parser.cc @@ -536,13 +536,13 @@ SnortConfig* ParseSnortConf(const SnortConfig* boot_conf, const char* fname) if ( *fname ) { - Shell* sh = sc->policy_map->get_shell(); + sh = sc->policy_map->get_shell(); sh->set_file(fname); } for ( unsigned i = 0; true; i++ ) { - Shell* sh = sc->policy_map->get_shell(i); + sh = sc->policy_map->get_shell(i); if ( !sh ) break; diff --git a/src/piglet/piglet_output.cc b/src/piglet/piglet_output.cc index 05b119c55..bb07d5b5a 100644 --- a/src/piglet/piglet_output.cc +++ b/src/piglet/piglet_output.cc @@ -85,7 +85,7 @@ const struct Output unit_test_output = [](const Summary& sum) -> void { printf( - "%f: Checks: %d, Failures: %d, Errors: %d\n", + "%f: Checks: %u, Failures: %u, Errors: %u\n", calc_percent(sum.passed, sum.total()), sum.total(), sum.failed, sum.errors ); @@ -96,7 +96,7 @@ const struct Output unit_test_output = [](const Test& t, unsigned i) -> void { printf( - "%s:%c:piglet:(%s::%s):%d: %s\n", + "%s:%c:piglet:(%s::%s):%u: %s\n", t.chunk->filename.c_str(), get_result_short(t.result), t.type.c_str(), t.name.c_str(), i, get_result_long(t.result) ); @@ -125,9 +125,9 @@ const struct Output pretty_output = // FIXIT-L don't want to include this if ( sum.failed || sum.errors ) { printf( - " - Passed: \x1b[32m%d\x1b[0m, " - "Failed: \x1b[31m%d\x1b[0m, " - "Errors: \x1b[33m%d\x1b[0m", + " - Passed: \x1b[32m%u\x1b[0m, " + "Failed: \x1b[31m%u\x1b[0m, " + "Errors: \x1b[33m%u\x1b[0m", sum.passed, sum.failed, sum.errors ); } @@ -137,7 +137,7 @@ const struct Output pretty_output = // FIXIT-L don't want to include this [](const Test& t, unsigned i) -> void { printf( - "%d) \x1b[34m%s::%s\x1b[0m: %s\n", + "%u) \x1b[34m%s::%s\x1b[0m: %s\n", i, t.type.c_str(), t.name.c_str(), t.chunk->filename.c_str() ); }, @@ -186,7 +186,7 @@ const struct Output verbose_output = { printf("=========================================\n"); printf( - "%0.f%% - passed: %d/%d, failed: %d, errors: %d\n", + "%0.f%% - passed: %u/%u, failed: %u, errors: %u\n", calc_percent(sum.passed, sum.total()), sum.passed, sum.total(), sum.failed, sum.errors ); diff --git a/src/ports/port_table.cc b/src/ports/port_table.cc index 6bc970d74..1e639a3c5 100644 --- a/src/ports/port_table.cc +++ b/src/ports/port_table.cc @@ -298,18 +298,18 @@ static PortObject2* _merge_N_pol( { for (i=1; irule_list->count,i); PortObjectAppendEx2(ponew, (PortObject*)pol[i]); DebugFormat(DEBUG_PORTLISTS, - "*** merged port-object[%d], %d rules\n", + "*** merged port-object[%d], %u rules\n", i,ponew->rule_hash->count); } PortObjectNormalize( (PortObject*)ponew); } DebugFormat(DEBUG_PORTLISTS, - "*** merged %d port objects, %d rules\n", + "*** merged %d port objects, %u rules\n", pol_cnt,ponew->rule_hash->count); DebugMessage(DEBUG_PORTLISTS,"*** merged ponew - follows: \n"); // PortObjectPrint2(ponew); diff --git a/src/profiler/rule_profiler.cc b/src/profiler/rule_profiler.cc index 5edde55ad..cfd7279d1 100644 --- a/src/profiler/rule_profiler.cc +++ b/src/profiler/rule_profiler.cc @@ -443,7 +443,6 @@ TEST_CASE( "otn state", "[profiler][rule_profiler]" ) TEST_CASE( "rule entry", "[profiler][rule_profiler]" ) { - SigInfo sig_info; auto entry = make_rule_entry(3_ticks, 2_ticks, 3, 2); entry.state.alerts = 77; entry.state.latency_timeouts = 5; diff --git a/src/protocols/ipv4_options.cc b/src/protocols/ipv4_options.cc index c901f5aa3..32d7f1aa2 100644 --- a/src/protocols/ipv4_options.cc +++ b/src/protocols/ipv4_options.cc @@ -32,7 +32,7 @@ const IpOptions& IpOptionIteratorIter::operator*() const IpOptionIterator::IpOptionIterator(const IP4Hdr* const ip4_header, const Packet* const p) { - const uint8_t* const hdr = (const uint8_t* const)ip4_header; + const uint8_t* const hdr = (const uint8_t*)ip4_header; start_ptr = hdr + IP4_HEADER_LEN; end_ptr = start_ptr; @@ -52,7 +52,7 @@ IpOptionIterator::IpOptionIterator(const IP4Hdr* const ip4_header, const Packet* IpOptionIterator::IpOptionIterator(const IP4Hdr* const ip4_header, const uint8_t valid_hdr_len) { - const uint8_t* const hdr = (const uint8_t* const)ip4_header; + const uint8_t* const hdr = (const uint8_t*)ip4_header; start_ptr = hdr + IP4_HEADER_LEN; if (valid_hdr_len < IP4_HEADER_LEN) diff --git a/src/protocols/protocol_ids.h b/src/protocols/protocol_ids.h index baff79f87..4c807f280 100644 --- a/src/protocols/protocol_ids.h +++ b/src/protocols/protocol_ids.h @@ -38,10 +38,10 @@ */ // Convert enum to a value cast to the enum's underlying type. -template -constexpr auto to_utype(En t)->typename std::underlying_type::type +template +inline constexpr typename std::underlying_type::type to_utype(E enumerator) { - return static_cast::type>(t); + return static_cast::type>(enumerator); } using ProtocolIndex = uint8_t; diff --git a/src/search_engines/hyperscan.cc b/src/search_engines/hyperscan.cc index 0961cc993..b2a035c42 100644 --- a/src/search_engines/hyperscan.cc +++ b/src/search_engines/hyperscan.cc @@ -195,7 +195,7 @@ void HyperscanMpse::user_dtor() int HyperscanMpse::prep_patterns(SnortConfig* sc) { - hs_compile_error_t* err = nullptr; + hs_compile_error_t* errptr = nullptr; std::vector pats; std::vector flags; std::vector ids; @@ -210,11 +210,11 @@ int HyperscanMpse::prep_patterns(SnortConfig* sc) } if ( hs_compile_multi(&pats[0], &flags[0], &ids[0], pvector.size(), HS_MODE_BLOCK, - nullptr, &hs_db, &err) or !hs_db ) + nullptr, &hs_db, &errptr) or !hs_db ) { - // FIXIT-L emit data from err + // FIXIT-L emit data from errptr ParseError("can't compile pattern database '%s'", "hs_compile_multi"); - hs_free_compile_error(err); + hs_free_compile_error(errptr); return -1; } diff --git a/src/service_inspectors/dce_rpc/dce_co.cc b/src/service_inspectors/dce_rpc/dce_co.cc index 6d949ab59..b06f29836 100644 --- a/src/service_inspectors/dce_rpc/dce_co.cc +++ b/src/service_inspectors/dce_rpc/dce_co.cc @@ -638,10 +638,10 @@ static void DCE2_CoCtxReq(DCE2_SsnData* sd, DCE2_CoTracker* cot, const DceRpcCoH } DebugFormat(DEBUG_DCE_COMMON, "Added Context item to queue.\n" - " Context id: %u\n" + " Context id: %hu\n" " Interface: %s\n" - " Interface major version: %u\n" - " Interface minor version: %u\n", + " Interface major version: %hu\n" + " Interface minor version: %hu\n", ctx_node->ctx_id, DCE2_UuidToStr(&ctx_node->iface, DCERPC_BO_FLAG__NONE), ctx_node->iface_vers_maj, ctx_node->iface_vers_min); @@ -688,10 +688,10 @@ static void dce_co_process_ctx_result(DCE2_SsnData* sd,DCE2_CoTracker* cot, } DebugFormat(DEBUG_DCE_COMMON, "Adding Context item to context item list.\n" - " Context id: %u\n" + " Context id: %hu\n" " Interface: %s\n" - " Interface major version: %u\n" - " Interface minor version: %u\n", + " Interface major version: %hu\n" + " Interface minor version: %hu\n", ctx_node->ctx_id, DCE2_UuidToStr(&ctx_node->iface, DCERPC_BO_FLAG__NONE), ctx_node->iface_vers_maj, ctx_node->iface_vers_min); @@ -2322,7 +2322,7 @@ void DCE2_CoProcess(DCE2_SsnData* sd, DCE2_CoTracker* cot, if (data_len < frag_len) { DebugFormat(DEBUG_DCE_COMMON, - "Not enough data in packet for fragment length: %u\n", frag_len); + "Not enough data in packet for fragment length: %hu\n", frag_len); /* Set frag length so we don't have to check it again in seg code */ seg->frag_len = frag_len; diff --git a/src/service_inspectors/dce_rpc/dce_common.cc b/src/service_inspectors/dce_rpc/dce_common.cc index 8ee127f7f..fa7ec2c52 100644 --- a/src/service_inspectors/dce_rpc/dce_common.cc +++ b/src/service_inspectors/dce_rpc/dce_common.cc @@ -144,13 +144,13 @@ static void DCE2_PrintRoptions(DCE2_Roptions* ropts) { DebugFormat(DEBUG_DCE_COMMON, " Iface: %s\n", DCE2_UuidToStr(&ropts->iface, DCERPC_BO_FLAG__NONE)); - DebugFormat(DEBUG_DCE_COMMON, " Iface version: %u\n", ropts->iface_vers_maj); + DebugFormat(DEBUG_DCE_COMMON, " Iface version: %hu\n", ropts->iface_vers_maj); } if (ropts->opnum == DCE2_SENTINEL) DebugMessage(DEBUG_DCE_COMMON, " Opnum: unset\n"); else { - DebugFormat(DEBUG_DCE_COMMON, " Opnum: %u\n", ropts->opnum); + DebugFormat(DEBUG_DCE_COMMON, " Opnum: %d\n", ropts->opnum); } if (ropts->stub_data != nullptr) DebugFormat(DEBUG_DCE_COMMON, " Stub data: %p\n", ropts->stub_data); diff --git a/src/service_inspectors/dce_rpc/dce_smb.cc b/src/service_inspectors/dce_rpc/dce_smb.cc index 6fc9f4a3f..1914e9800 100644 --- a/src/service_inspectors/dce_rpc/dce_smb.cc +++ b/src/service_inspectors/dce_rpc/dce_smb.cc @@ -736,7 +736,7 @@ static DCE2_SmbRequestTracker* DCE2_SmbFindRequestTracker(DCE2_SmbSsnData* ssd, Profile profile(dce2_smb_pstat_smb_req); DebugFormat(DEBUG_DCE_SMB, "Find request tracker => " - "Uid: %u, Tid: %u, Pid: %u, Mid: %u ... ", uid, tid, pid, mid); + "Uid: %hu, Tid: %hu, Pid: %hu, Mid: %hu ... ", uid, tid, pid, mid); DCE2_SmbRequestTracker* tmp_rtracker = &ssd->rtracker; int smb_com = SmbCom(smb_hdr); @@ -1346,7 +1346,7 @@ static DCE2_SmbRequestTracker* DCE2_SmbInspect(DCE2_SmbSsnData* ssd, const SmbNt if (DCE2_SmbFindTid(ssd, SmbTid(smb_hdr)) != DCE2_RET__SUCCESS) { DebugFormat(DEBUG_DCE_SMB, - "Couldn't find Tid (%u)\n", SmbTid(smb_hdr)); + "Couldn't find Tid (%hu)\n", SmbTid(smb_hdr)); return nullptr; } @@ -1830,7 +1830,7 @@ static void DCE2_SmbProcess(DCE2_SmbSsnData* ssd) // See if there is enough data to process the NetBIOS header if (data_len < data_need) { - DebugFormat(DEBUG_DCE_SMB, "Data len(%u) < NetBIOS SS header(%u). " + DebugFormat(DEBUG_DCE_SMB, "Data len(%hu) < NetBIOS SS header(%u). " "Queueing data.\n", data_len, data_need); // FIXIT-M port segmentation code @@ -1897,7 +1897,7 @@ static void DCE2_SmbProcess(DCE2_SmbSsnData* ssd) // See if there is enough data to process the SMB header if (data_len < data_need) { - DebugFormat(DEBUG_DCE_SMB, "Data len (%u) < " + DebugFormat(DEBUG_DCE_SMB, "Data len (%hu) < " "NetBIOS SS header + SMB header (%u). Queueing data.\n", data_len, data_need); diff --git a/src/service_inspectors/dce_rpc/dce_smb_commands.cc b/src/service_inspectors/dce_rpc/dce_smb_commands.cc index a517868a8..0d306868f 100644 --- a/src/service_inspectors/dce_rpc/dce_smb_commands.cc +++ b/src/service_inspectors/dce_rpc/dce_smb_commands.cc @@ -1728,12 +1728,12 @@ DCE2_Ret DCE2_SmbTreeConnectAndX(DCE2_SmbSsnData* ssd, const SmbNtHdr* smb_hdr, { case SERVICE_IPC: DebugFormat(DEBUG_DCE_SMB, - "Tid (%u) is an IPC tree.\n", tid); + "Tid (%hu) is an IPC tree.\n", tid); break; case SERVICE_DISK: is_ipc = false; DebugFormat(DEBUG_DCE_SMB, - "Tid (%u) is a DISK tree.\n", tid); + "Tid (%hu) is a DISK tree.\n", tid); break; default: return DCE2_RET__IGNORE; @@ -1844,7 +1844,7 @@ DCE2_Ret DCE2_SmbTreeConnect(DCE2_SmbSsnData* ssd, const SmbNtHdr* smb_hdr, uint16_t tid = SmbTid(smb_hdr); DCE2_SmbInsertTid(ssd, tid, ssd->cur_rtracker->is_ipc); - DebugFormat(DEBUG_DCE_SMB, "Tid (%u) %s an IPC tree\n", tid, + DebugFormat(DEBUG_DCE_SMB, "Tid (%hu) %s an IPC tree\n", tid, (ssd->cur_rtracker->is_ipc) ? "is" : "is not"); } diff --git a/src/service_inspectors/dce_rpc/dce_smb_utils.cc b/src/service_inspectors/dce_rpc/dce_smb_utils.cc index 0dbf1370d..6c01ff76e 100644 --- a/src/service_inspectors/dce_rpc/dce_smb_utils.cc +++ b/src/service_inspectors/dce_rpc/dce_smb_utils.cc @@ -151,7 +151,7 @@ void DCE2_SmbInsertUid(DCE2_SmbSsnData* ssd, const uint16_t uid) { Profile profile(dce2_smb_pstat_smb_uid); - DebugFormat(DEBUG_DCE_SMB, "Inserting Uid: %u\n", uid); + DebugFormat(DEBUG_DCE_SMB, "Inserting Uid: %hu\n", uid); if (ssd->uid == DCE2_SENTINEL) { @@ -180,7 +180,7 @@ void DCE2_SmbRemoveUid(DCE2_SmbSsnData* ssd, const uint16_t uid) Profile profile(dce2_smb_pstat_smb_uid); - DebugFormat(DEBUG_DCE_SMB,"Removing Uid: %u\n", uid); + DebugFormat(DEBUG_DCE_SMB,"Removing Uid: %hu\n", uid); if ((ssd->uid != DCE2_SENTINEL) && (ssd->uid == (int)uid)) ssd->uid = DCE2_SENTINEL; @@ -326,10 +326,10 @@ DCE2_SmbRequestTracker* DCE2_SmbNewRequestTracker(DCE2_SmbSsnData* ssd, dce2_smb_stats.smb_max_outstanding_requests = ssd->outstanding_requests; DebugFormat(DEBUG_DCE_SMB, "Added new request tracker => " - "Uid: %u, Tid: %u, Pid: %u, Mid: %u\n", + "Uid: %hu, Tid: %hu, Pid: %hu, Mid: %d\n", rtracker->uid, rtracker->tid, rtracker->pid, rtracker->mid); DebugFormat(DEBUG_DCE_SMB, - "Current outstanding requests: %u\n", ssd->outstanding_requests); + "Current outstanding requests: %hu\n", ssd->outstanding_requests); return rtracker; } @@ -347,7 +347,7 @@ DCE2_SmbFileTracker* DCE2_SmbNewFileTracker(DCE2_SmbSsnData* ssd, return nullptr; DebugFormat(DEBUG_DCE_SMB, "Creating new file tracker " - "with Uid: %u, Tid: %u, Fid: 0x%04X\n", uid, tid, fid); + "with Uid: %hu, Tid: %hu, Fid: 0x%04X\n", uid, tid, fid); DCE2_SmbFileTracker* ftracker = nullptr; if (ssd->ftracker.fid == DCE2_SENTINEL) @@ -449,7 +449,7 @@ DCE2_SmbFileTracker* DCE2_SmbFindFileTracker(DCE2_SmbSsnData* ssd, Profile profile(dce2_smb_pstat_smb_fid); DebugFormat(DEBUG_DCE_SMB, "Finding file tracker with " - "Uid: %u, Tid: %u, Fid: 0x%04X ... ", uid, tid, fid); + "Uid: %hu, Tid: %hu, Fid: 0x%04X ... ", uid, tid, fid); DCE2_SmbFileTracker* ftracker; if ((ssd->ftracker.fid != DCE2_SENTINEL) && (ssd->ftracker.fid == (int)fid)) @@ -523,7 +523,7 @@ DCE2_SmbFileTracker* DCE2_SmbFindFileTracker(DCE2_SmbSsnData* ssd, } DebugFormat(DEBUG_DCE_SMB, "Found with " - "Uid: %u, Tid: %u, Fid: 0x%04X\n", + "Uid: %hu, Tid: %hu, Fid: 0x%04X\n", ftracker->uid, ftracker->tid, ftracker->fid); return ftracker; } @@ -645,7 +645,7 @@ void DCE2_SmbFileTrackerDataFree(void* data) return; DebugFormat(DEBUG_DCE_SMB, "Freeing file tracker: " - "Uid: %u, Tid: %u, Fid: 0x%04X\n", + "Uid: %hu, Tid: %hu, Fid: 0x%04X\n", ftracker->uid, ftracker->tid, ftracker->fid); DCE2_SmbCleanFileTracker(ftracker); @@ -724,7 +724,7 @@ void DCE2_SmbRemoveRequestTracker(DCE2_SmbSsnData* ssd, } DebugFormat(DEBUG_DCE_SMB, "Removing request tracker => " - "Uid: %u, Tid: %u, Pid: %u, Mid: %u ... ", + "Uid: %hu, Tid: %hu, Pid: %hu, Mid: %d ... ", rtracker->uid, rtracker->tid, rtracker->pid, rtracker->mid); if (rtracker == &ssd->rtracker) @@ -838,7 +838,7 @@ void DCE2_SmbRequestTrackerDataFree(void* data) return; DebugFormat(DEBUG_DCE_SMB, "Freeing request tracker: " - "Uid: %u, Tid: %u, Pid: %u, Mid: %u\n", + "Uid: %hu, Tid: %hu, Pid: %hu, Mid: %d\n", rtracker->uid, rtracker->tid, rtracker->pid, rtracker->mid); DCE2_SmbCleanRequestTracker(rtracker); @@ -863,7 +863,7 @@ void DCE2_SmbRemoveTid(DCE2_SmbSsnData* ssd, const uint16_t tid) { Profile profile(dce2_smb_pstat_smb_tid); - DebugFormat(DEBUG_DCE_SMB, "Removing Tid: %u\n", tid); + DebugFormat(DEBUG_DCE_SMB, "Removing Tid: %hu\n", tid); if ((ssd->tid != DCE2_SENTINEL) && ((ssd->tid & 0x0000ffff) == (int)tid)) ssd->tid = DCE2_SENTINEL; @@ -913,7 +913,7 @@ void DCE2_SmbInsertTid(DCE2_SmbSsnData* ssd, || ((ssd->max_file_depth == -1) && DCE2_ScSmbFileDepth( (dce2SmbProtoConf*)ssd->sd.config) == -1))) { - DebugFormat(DEBUG_DCE_SMB, "Not inserting TID (%u) " + DebugFormat(DEBUG_DCE_SMB, "Not inserting TID (%hu) " "because it's not IPC and not inspecting normal file " "data.", tid); return; @@ -921,13 +921,13 @@ void DCE2_SmbInsertTid(DCE2_SmbSsnData* ssd, if (is_ipc && DCE2_ScSmbFileInspectionOnly((dce2SmbProtoConf*)ssd->sd.config)) { - DebugFormat(DEBUG_DCE_SMB, "Not inserting TID (%u) " + DebugFormat(DEBUG_DCE_SMB, "Not inserting TID (%hu) " "because it's IPC and only inspecting normal file " "data.", tid); return; } - DebugFormat(DEBUG_DCE_SMB, "Inserting Tid: %u\n", tid); + DebugFormat(DEBUG_DCE_SMB, "Inserting Tid: %hu\n", tid); int insert_tid = (int)tid; // Set a bit so as to distinguish between IPC and non-IPC TIDs if (!is_ipc) @@ -1027,7 +1027,7 @@ void DCE2_SmbQueueTmpFileTracker(DCE2_SmbSsnData* ssd, Profile profile(dce2_smb_pstat_smb_fid); DebugFormat(DEBUG_DCE_SMB, "Queueing file tracker " - "with Uid: %u, Tid: %u\n", uid, tid); + "with Uid: %hu, Tid: %hu\n", uid, tid); DCE2_SmbFileTracker* ftracker = (DCE2_SmbFileTracker*) snort_calloc(sizeof(DCE2_SmbFileTracker)); diff --git a/src/service_inspectors/dce_rpc/dce_tcp_paf.cc b/src/service_inspectors/dce_rpc/dce_tcp_paf.cc index c197902a1..24f098a5f 100644 --- a/src/service_inspectors/dce_rpc/dce_tcp_paf.cc +++ b/src/service_inspectors/dce_rpc/dce_tcp_paf.cc @@ -97,7 +97,7 @@ static StreamSplitter::Status dce2_tcp_paf(DCE2_PafTcpData* ds, Flow* flow, cons } } - DebugFormat(DEBUG_DCE_TCP, "Start state: %u\n", ds->paf_state); + DebugFormat(DEBUG_DCE_TCP, "Start state: %d\n", ds->paf_state); start_state = (uint8_t)ds->paf_state; while (n < len) @@ -140,7 +140,7 @@ static StreamSplitter::Status dce2_tcp_paf(DCE2_PafTcpData* ds, Flow* flow, cons return StreamSplitter::ABORT; } - DebugFormatNoFileLine(DEBUG_DCE_TCP, "Fragment length: %u\n", ds->frag_len); + DebugFormatNoFileLine(DEBUG_DCE_TCP, "Fragment length: %hu\n", ds->frag_len); /* Increment n here so we can continue */ n += ds->frag_len - (uint8_t)ds->paf_state; @@ -149,7 +149,7 @@ static StreamSplitter::Status dce2_tcp_paf(DCE2_PafTcpData* ds, Flow* flow, cons * flush just before it */ if ((num_requests == 1) || (n <= len)) tmp_fp += ds->frag_len; - DebugFormatNoFileLine(DEBUG_DCE_TCP, "Requests: %u\n", num_requests); + DebugFormatNoFileLine(DEBUG_DCE_TCP, "Requests: %d\n", num_requests); ds->paf_state = DCE2_PAF_TCP_STATES__0; continue; // we incremented n already default: diff --git a/src/service_inspectors/dns/dns.cc b/src/service_inspectors/dns/dns.cc index cfad96364..2af9ca68b 100644 --- a/src/service_inspectors/dns/dns.cc +++ b/src/service_inspectors/dns/dns.cc @@ -873,8 +873,8 @@ static void ParseDNSResponseMessage(Packet* p, DNSData* dnsSessionData) { case DNS_RESP_STATE_RR_RDATA_START: DebugFormat(DEBUG_DNS, - "DNS ANSWER RR %d: type %d, class %d, " - "ttl %d rdlength %d\n", i, + "DNS ANSWER RR %d: type %hu, class %hu, " + "ttl %u rdlength %hu\n", i, dnsSessionData->curr_rr.type, dnsSessionData->curr_rr.dns_class, dnsSessionData->curr_rr.ttl, @@ -926,8 +926,8 @@ static void ParseDNSResponseMessage(Packet* p, DNSData* dnsSessionData) { case DNS_RESP_STATE_RR_RDATA_START: DebugFormat(DEBUG_DNS, - "DNS AUTH RR %d: type %d, class %d, " - "ttl %d rdlength %d\n", i, + "DNS AUTH RR %d: type %hu, class %hu, " + "ttl %u rdlength %hu\n", i, dnsSessionData->curr_rr.type, dnsSessionData->curr_rr.dns_class, dnsSessionData->curr_rr.ttl, @@ -979,8 +979,8 @@ static void ParseDNSResponseMessage(Packet* p, DNSData* dnsSessionData) { case DNS_RESP_STATE_RR_RDATA_START: DebugFormat(DEBUG_DNS, - "DNS ADDITONAL RR %d: type %d, class %d, " - "ttl %d rdlength %d\n", i, + "DNS ADDITONAL RR %d: type %hu, class %hu, " + "ttl %u rdlength %hu\n", i, dnsSessionData->curr_rr.type, dnsSessionData->curr_rr.dns_class, dnsSessionData->curr_rr.ttl, diff --git a/src/service_inspectors/http_inspect/hi_stream_splitter.cc b/src/service_inspectors/http_inspect/hi_stream_splitter.cc index 9ea511c61..89625202c 100644 --- a/src/service_inspectors/http_inspect/hi_stream_splitter.cc +++ b/src/service_inspectors/http_inspect/hi_stream_splitter.cc @@ -585,7 +585,7 @@ static void hi_link_check() static bool hi_fsm_compile() { - unsigned i = 0, j; + unsigned i = 0; unsigned max = sizeof(hi_rule) / sizeof(hi_rule[0]); unsigned next, extra = 0; @@ -607,12 +607,12 @@ static bool hi_fsm_compile() next = max; for ( i = 0; i < hi_fsm_size; i++ ) - for ( j = 0; j < 256; j++ ) + for ( int j = 0; j < 256; j++ ) hi_fsm[i].cell[j].next = TBD; for ( i = 0; i < max; i++ ) { - int prev = i, j, n = strlen(hi_rule[i].event); + int prev = i, n = strlen(hi_rule[i].event); const char* event = hi_rule[i].event; hi_link(hi_fsm+i, event, hi_rule+i); @@ -622,7 +622,7 @@ static bool hi_fsm_compile() printf("Expanding %s at %u\n", hi_rule[i].event, next); #endif - for ( j = 1; j < n; j++ ) + for ( int j = 1; j < n; j++ ) { event = hi_rule[i].event + j; hi_link(hi_fsm+next, event, hi_rule+i); @@ -802,7 +802,7 @@ static void hi_pipe_push(Hi5State* s_req, Flow* ssn) uint32_t nreq = s_req->pipe & 0xFF; uint32_t pipe = s_req->pipe >> 8; - DebugFormat(DEBUG_STREAM_PAF, "%s: nreq=%d, pipe=0x%X\n", __func__, nreq, pipe); + DebugFormat(DEBUG_STREAM_PAF, "%s: nreq=%u, pipe=0x%X\n", __func__, nreq, pipe); if ( nreq == MAX_PIPELINE ) { @@ -830,7 +830,7 @@ static void hi_pipe_pop(Hi5State* s_rsp, Flow* ssn) uint32_t nreq = s_req->pipe & 0xFF; uint32_t pipe = s_req->pipe >> 8; - DebugFormat(DEBUG_STREAM_PAF, "%s: nreq=%d, pipe=0x%X\n", __func__, nreq, pipe); + DebugFormat(DEBUG_STREAM_PAF, "%s: nreq=%u, pipe=0x%X\n", __func__, nreq, pipe); // FIXIT-L valgrind: Conditional jump or move depends on uninitialised value(s) if ( nreq == 0 || nreq == PIPELINE_RUPTURED ) @@ -885,7 +885,7 @@ static StreamSplitter::Status hi_scan_fsm(Hi5State* s, int c) get_state(prev, before, sizeof(before)); get_state(s->fsm, after, sizeof(after)); DebugFormat(DEBUG_STREAM_PAF, - "%s: %s(%u)[0x%2X, '%c'] -> %d,%s(%u)\n", + "%s: %s(%hhu)[0x%2X, '%c'] -> %d,%s(%hhu)\n", __func__, before, prev, c, isgraph(c) ? c : '.', cell->action, after, s->fsm); #endif @@ -1045,7 +1045,7 @@ static void hi_reset(Hi5State* s, uint32_t flags) } s->flags = 0; - DebugFormat(DEBUG_STREAM_PAF, "%s: fsm=%u, flags=0x%X\n", __func__, s->fsm, s->flags); + DebugFormat(DEBUG_STREAM_PAF, "%s: fsm=%hhu, flags=0x%X\n", __func__, s->fsm, s->flags); } //-------------------------------------------------------------------- diff --git a/src/service_inspectors/rpc_decode/rpc_decode.cc b/src/service_inspectors/rpc_decode/rpc_decode.cc index bf9b6d1a1..8b6b92617 100644 --- a/src/service_inspectors/rpc_decode/rpc_decode.cc +++ b/src/service_inspectors/rpc_decode/rpc_decode.cc @@ -207,7 +207,7 @@ static RpcStatus RpcStatefulInspection(RpcDecodeConfig* rconfig, if (dsize < rsdata->ignore) { DebugFormat(DEBUG_RPC, - "STATEFUL: Ignoring %u bytes\n", dsize); + "STATEFUL: Ignoring %hu bytes\n", dsize); rsdata->ignore -= dsize; @@ -237,7 +237,7 @@ static RpcStatus RpcStatefulInspection(RpcDecodeConfig* rconfig, if (dsize < RPC_FRAG_HDR_SIZE) { DebugFormat(DEBUG_RPC, - "STATEFUL: Not enough data for frag header: %u\n", + "STATEFUL: Not enough data for frag header: %hu\n", dsize); RpcPreprocEvent(rconfig, rsdata, RPC_INCOMPLETE_SEGMENT); @@ -256,7 +256,7 @@ static RpcStatus RpcStatefulInspection(RpcDecodeConfig* rconfig, if (dsize < (RPC_FRAG_HDR_SIZE + rsdata->frag_len)) { DebugFormat(DEBUG_RPC, - "STATEFUL: Not enough data for fragment: %u\n", + "STATEFUL: Not enough data for fragment: %hu\n", dsize); RpcPreprocEvent(rconfig, rsdata, RPC_INCOMPLETE_SEGMENT); @@ -304,7 +304,7 @@ static RpcStatus RpcStatefulInspection(RpcDecodeConfig* rconfig, { DebugFormat(DEBUG_RPC, "STATEFUL: Not enough data for frag header " - "(%u): %u\n", need, dsize); + "(%d): %hu\n", need, dsize); RpcPreprocEvent(rconfig, rsdata, RPC_INCOMPLETE_SEGMENT); @@ -330,7 +330,7 @@ static RpcStatus RpcStatefulInspection(RpcDecodeConfig* rconfig, if (dsize < need) { DebugFormat(DEBUG_RPC, - "STATEFUL: Not enough data for fragment (%u): %u\n", + "STATEFUL: Not enough data for fragment (%d): %hu\n", need, dsize); RpcPreprocEvent(rconfig, rsdata, RPC_INCOMPLETE_SEGMENT); @@ -769,13 +769,13 @@ static int ConvertRPC(RpcDecodeConfig* rconfig, RpcSsnData* rsdata, Packet* p) if ((length + 4 != psize) && !(p->packet_flags & PKT_REBUILT_STREAM)) { DebugFormat(DEBUG_RPC, "It's not the only thing in this buffer!" - " length: %d psize: %d!\n", length, psize); + " length: %u psize: %u!\n", length, psize); return RPC_MULTIPLE_RECORD; } else if ( length == 0 ) { DebugFormat(DEBUG_RPC, "Zero-length RPC fragment detected." - " length: %d psize: %d.\n", length, psize); + " length: %u psize: %u.\n", length, psize); return RPC_ZERO_LENGTH_FRAGMENT; } return 0; @@ -838,7 +838,7 @@ static int ConvertRPC(RpcDecodeConfig* rconfig, RpcSsnData* rsdata, Packet* p) * psize's might be allowed */ DebugFormat(DEBUG_RPC, "Integer Overflow" - " field(%d) exceeds packet size(%d)\n", + " field(%u) exceeds packet size(%u)\n", length, psize); return RPC_LARGE_FRAGSIZE; } @@ -848,7 +848,7 @@ static int ConvertRPC(RpcDecodeConfig* rconfig, RpcSsnData* rsdata, Packet* p) if (length > psize) { DebugFormat(DEBUG_RPC, "Length of" - " field(%d) exceeds packet size(%d)\n", + " field(%u) exceeds packet size(%u)\n", length, psize); return RPC_INCOMPLETE_SEGMENT; } @@ -857,8 +857,8 @@ static int ConvertRPC(RpcDecodeConfig* rconfig, RpcSsnData* rsdata, Packet* p) /* The entire request is larger than our current packet * size */ - DebugFormat(DEBUG_RPC, " Decoded Length (%d)" - "exceeds packet size(%d)\n", + DebugFormat(DEBUG_RPC, " Decoded Length (%u)" + "exceeds packet size(%u)\n", decoded_len, psize); return RPC_LARGE_FRAGSIZE; } @@ -874,7 +874,7 @@ static int ConvertRPC(RpcDecodeConfig* rconfig, RpcSsnData* rsdata, Packet* p) fragcount++; DebugFormat(DEBUG_RPC, - "length: %d size: %d decoded_len: %d\n", + "length: %u size: %u decoded_len: %u\n", length, psize, decoded_len); ret = SafeMemcpy(norm_index, data_index, length, decode_buf_start, decode_buf_end); @@ -906,12 +906,12 @@ static int ConvertRPC(RpcDecodeConfig* rconfig, RpcSsnData* rsdata, Packet* p) */ if (decoded_len + ((fragcount - 1) * 4) != psize) { - DebugFormat(DEBUG_RPC, "decoded len does not compute: %d\n", + DebugFormat(DEBUG_RPC, "decoded len does not compute: %u\n", decoded_len); return RPC_MULTIPLE_RECORD; } - DebugFormat(DEBUG_RPC, "New size: %d\n", decoded_len); + DebugFormat(DEBUG_RPC, "New size: %u\n", decoded_len); DebugMessage(DEBUG_RPC, "converted data:\n"); //LogNetData(data, decoded_len, p); diff --git a/src/service_inspectors/sip/sip_dialog.cc b/src/service_inspectors/sip/sip_dialog.cc index dc08d70c4..47122c8fd 100644 --- a/src/service_inspectors/sip/sip_dialog.cc +++ b/src/service_inspectors/sip/sip_dialog.cc @@ -49,7 +49,7 @@ static SIP_DialogData* SIP_addDialog(SIPMsg*, SIP_DialogData*, SIP_DialogList*); static int SIP_deleteDialog(SIP_DialogData*, SIP_DialogList*); #ifdef DEBUG_MSGS -void SIP_displayMedias(SIP_MediaList* dList); +static void SIP_displayMedias(SIP_MediaList* dList); #endif /******************************************************************** @@ -149,7 +149,7 @@ static int SIP_processInvite(SIPMsg* sipMsg, SIP_DialogData* dialog, SIP_DialogL // check whether this invite has authorization information if ((SIP_DLG_AUTHENCATING != dialog->state) && (NULL != sipMsg->authorization)) { - DebugFormat(DEBUG_SIP, "Dialog state code: %u\n", + DebugFormat(DEBUG_SIP, "Dialog state code: %hu\n", dialog->status_code); SnortEventqAdd(GID_SIP, SIP_EVENT_AUTH_INVITE_REPLAY_ATTACK); @@ -402,9 +402,9 @@ static int SIP_ignoreChannels(SIP_DialogData* dialog, Packet* p, SIP_PROTO_CONF* while ((NULL != mdataA)&&(NULL != mdataB)) { //void *ssn; - DebugFormat(DEBUG_SIP, "Ignoring channels Source IP: %s Port: %u\n", + DebugFormat(DEBUG_SIP, "Ignoring channels Source IP: %s Port: %hu\n", sfip_to_str(&mdataA->maddress), mdataA->mport); - DebugFormat(DEBUG_SIP, "Ignoring channels Destine IP: %s Port: %u\n", + DebugFormat(DEBUG_SIP, "Ignoring channels Destine IP: %s Port: %hu\n", sfip_to_str(&mdataB->maddress), mdataB->mport); /* Call into Streams to mark data channel as something to ignore. */ @@ -544,7 +544,7 @@ void SIP_displayMedias(SIP_MediaList* dList) mdata = currSession->medias; while (NULL != mdata) { - DebugFormat(DEBUG_SIP, "Media IP: %s, port: %u, number of ports %u\n", + DebugFormat(DEBUG_SIP, "Media IP: %s, port: %hu, number of ports %hhu\n", sfip_to_str(&mdata->maddress), mdata->mport, mdata->numPort); mdata = mdata->nextM; } @@ -573,7 +573,7 @@ static SIP_DialogData* SIP_addDialog(SIPMsg* sipMsg, SIP_DialogData* currDialog, { SIP_DialogData* dialog; - DebugFormat(DEBUG_SIP, "Add Dialog id: %u, From: %u, To: %u, status code: %u\n", + DebugFormat(DEBUG_SIP, "Add Dialog id: %u, From: %u, To: %u, status code: %hu\n", sipMsg->dlgID.callIdHash,sipMsg->dlgID.fromTagHash,sipMsg->dlgID.toTagHash, sipMsg->status_code); diff --git a/src/service_inspectors/sip/sip_parser.cc b/src/service_inspectors/sip/sip_parser.cc index b74aaac27..4694fe393 100644 --- a/src/service_inspectors/sip/sip_parser.cc +++ b/src/service_inspectors/sip/sip_parser.cc @@ -416,7 +416,7 @@ static int sip_startline_parse(SIPMsg* msg, const char* buff, char* end, char** if (space == NULL) return false; msg->uriLen = space - msg->uri; - DebugFormat(DEBUG_SIP, "uri: %.*s, length: %u\n", msg->uriLen, msg->uri, + DebugFormat(DEBUG_SIP, "uri: %.*s, length: %hu\n", msg->uriLen, msg->uri, msg->uriLen); if (0 == msg->uriLen) SnortEventqAdd(GID_SIP, SIP_EVENT_EMPTY_REQUEST_URI); @@ -1203,7 +1203,7 @@ static int sip_parse_sdp_m(SIPMsg* msg, const char* start, const char* end) mdata->nextM = msg->mediaSession->medias; mdata->maddress = msg->mediaSession->maddress_default; msg->mediaSession->medias = mdata; - DebugFormat(DEBUG_SIP, "Media IP: %s, Media port %u, number of media: %d\n", + DebugFormat(DEBUG_SIP, "Media IP: %s, Media port %hu, number of media: %d\n", sfip_to_str(&mdata->maddress), mdata->mport, mdata->numPort); return SIP_PARSE_SUCCESS; } diff --git a/src/service_inspectors/smtp/smtp_paf.cc b/src/service_inspectors/smtp/smtp_paf.cc index 252225bd9..ecaa1d707 100644 --- a/src/service_inspectors/smtp/smtp_paf.cc +++ b/src/service_inspectors/smtp/smtp_paf.cc @@ -228,7 +228,7 @@ static inline bool process_command(SmtpPafData* pfdata, uint8_t val) /* Continue finding the data length ...*/ if (get_length(val, &pfdata->length) != SMTP_PAF_LENGTH_CONTINUE) { - DebugFormat(DEBUG_SMTP, "Find data length: %d\n", + DebugFormat(DEBUG_SMTP, "Find data length: %u\n", pfdata->length); pfdata->cmd_info.cmd_state = SMTP_PAF_CMD_DATA_END_STATE; } diff --git a/src/sfrt/sfrt_test.cc b/src/sfrt/sfrt_test.cc index 0f8c64d20..7ca7d6c82 100644 --- a/src/sfrt/sfrt_test.cc +++ b/src/sfrt/sfrt_test.cc @@ -70,7 +70,7 @@ static void test_sfrt_remove_after_insert() num_entries = sizeof(ip_lists)/sizeof(ip_lists[0]); if ( s_debug ) - printf("Number of entries: %d \n",num_entries); + printf("Number of entries: %u \n",num_entries); dir = sfrt_new(DIR_16_4x4_16x5_4x4, IPv6, num_entries + 1, 200); @@ -144,8 +144,8 @@ static void test_sfrt_remove_after_insert() if ( s_debug ) { - printf("Usage: %d bytes\n", sfrt_usage(dir)); - printf("Number of entries: %d \n", sfrt_num_entries(dir)); + printf("Usage: %u bytes\n", sfrt_usage(dir)); + printf("Number of entries: %u \n", sfrt_num_entries(dir)); } sfrt_free(dir); @@ -161,7 +161,7 @@ static void test_sfrt_remove_after_insert_all() num_entries = sizeof(ip_lists)/sizeof(ip_lists[0]); if ( s_debug ) - printf("Number of entries: %d \n",num_entries); + printf("Number of entries: %u \n",num_entries); dir = sfrt_new(DIR_16_4x4_16x5_4x4, IPv6, num_entries + 1, 200); @@ -207,8 +207,8 @@ static void test_sfrt_remove_after_insert_all() if ( s_debug ) { - printf("Usage: %d bytes\n", sfrt_usage(dir)); - printf("Number of entries: %d \n", sfrt_num_entries(dir)); + printf("Usage: %u bytes\n", sfrt_usage(dir)); + printf("Number of entries: %u \n", sfrt_num_entries(dir)); } /*remove all entries*/ @@ -235,7 +235,7 @@ static void test_sfrt_remove_after_insert_all() /*check the next entry still exist*/ if (index + 1 < num_entries) { - IP_entry* ip_entry = &(ip_lists[index + 1]); + ip_entry = &(ip_lists[index + 1]); /*Parse IP*/ if (ip_entry->ip_str) sfip_pton(ip_entry->ip_str, &ip); @@ -245,8 +245,8 @@ static void test_sfrt_remove_after_insert_all() if ( s_debug ) { - printf("Usage: %d bytes\n", sfrt_usage(dir)); - printf("Number of entries: %d \n", sfrt_num_entries(dir)); + printf("Usage: %u bytes\n", sfrt_usage(dir)); + printf("Number of entries: %u \n", sfrt_num_entries(dir)); } sfrt_free(dir); diff --git a/src/stream/ip/ip_defrag.cc b/src/stream/ip/ip_defrag.cc index ed8f6dd7c..78d95e300 100644 --- a/src/stream/ip/ip_defrag.cc +++ b/src/stream/ip/ip_defrag.cc @@ -497,8 +497,8 @@ static inline int FragCheckFirstLast(const Packet* const p, { ft->calculated_size = endOfThisFrag; - DebugFormat(DEBUG_FRAG, "Got last frag, Bytes: %d, " - "Calculated size: %d\n", + DebugFormat(DEBUG_FRAG, "Got last frag, Bytes: %u, " + "Calculated size: %u\n", ft->frag_bytes, ft->calculated_size); } @@ -618,7 +618,7 @@ static inline int checkTinyFragments( if (p->dsize <= engine->min_fragment_length) { DebugFormat(DEBUG_FRAG, - "Frag: Received fragment size(%d) is not more than configured min_fragment_length (%d)\n", + "Frag: Received fragment size(%d) is not more than configured min_fragment_length (%u)\n", p->dsize, engine->min_fragment_length); EventTinyFragments(engine); return 1; @@ -628,7 +628,7 @@ static inline int checkTinyFragments( if (trimmedLength <= engine->min_fragment_length) { DebugFormat(DEBUG_FRAG, - "Frag: # of New octets in Received fragment(%d) is not more than configured min_fragment_length (%d)\n", + "Frag: # of New octets in Received fragment(%u) is not more than configured min_fragment_length (%u)\n", trimmedLength, engine->min_fragment_length); EventTinyFragments(engine); return 1; @@ -707,7 +707,7 @@ static inline int FragIsComplete(FragTracker* ft) } DebugFormat(DEBUG_FRAG, - " Calc size (%d) != frag bytes (%d)\n", + " Calc size (%u) != frag bytes (%u)\n", ft->calculated_size, ft->frag_bytes); /* @@ -1150,7 +1150,7 @@ void Defrag::process(Packet* p, FragTracker* ft) { DebugFormat(DEBUG_FRAG, "[FRAG] Fragment discarded due to low TTL " - "[0x%X->0x%X], TTL: %d " "Offset: %d Length: %d\n", + "[0x%X->0x%X], TTL: %d " "Offset: %d Length: %hu\n", ntohl(p->ptrs.ip_api.get_ip4h()->get_src()), ntohl(p->ptrs.ip_api.get_ip4h()->get_dst()), p->ptrs.ip_api.ttl(), frag_offset, @@ -1214,7 +1214,7 @@ void Defrag::process(Packet* p, FragTracker* ft) { case FRAG_INSERT_FAILED: DebugFormat(DEBUG_FRAG, "WARNING: Insert into Fraglist failed, " - "(offset: %u).\n", frag_offset); + "(offset: %hu).\n", frag_offset); return; case FRAG_INSERT_TTL: @@ -1225,7 +1225,7 @@ void Defrag::process(Packet* p, FragTracker* ft) DebugFormat(DEBUG_FRAG, "[FRAG] Fragment discarded due to large TTL Delta " "[0x%X->0x%X], TTL: %d orig TTL: %d " - "Offset: %d Length: %d\n", + "Offset: %hu Length: %hu\n", ntohl(p->ptrs.ip_api.get_ip4h()->get_src()), ntohl(p->ptrs.ip_api.get_ip4h()->get_dst()), p->ptrs.ip_api.ttl(), ft->ttl, frag_offset, @@ -1242,13 +1242,13 @@ void Defrag::process(Packet* p, FragTracker* ft) case FRAG_INSERT_TIMEOUT: DebugFormat(DEBUG_FRAG, "WARNING: Insert into Fraglist failed due to timeout, " - "(offset: %u).\n", frag_offset); + "(offset: %hu).\n", frag_offset); return; case FRAG_INSERT_OVERLAP_LIMIT: DebugFormat(DEBUG_FRAG, "WARNING: Excessive IP fragment overlap, " - "(More: %u, offset: %u, offsetSize: %u).\n", + "(More: %d, offset: %d, offsetSize: %hu).\n", (p->ptrs.decode_flags & DECODE_MF), (frag_offset << 3), p->dsize); ip_stats.discards++; @@ -2288,7 +2288,7 @@ int Defrag::add_frag_node( ft->frag_bytes += newfrag->size; DebugFormat(DEBUG_FRAG, - "[#] accumulated bytes on FragTracker %d, count" + "[#] accumulated bytes on FragTracker %u, count" " %d\n", ft->frag_bytes, ft->fraglist_count); *retFrag = newfrag; @@ -2361,7 +2361,7 @@ int Defrag::dup_frag_node( ft->frag_bytes += newfrag->size; DebugFormat(DEBUG_FRAG, - "[#] accumulated bytes on FragTracker %d, count" + "[#] accumulated bytes on FragTracker %u, count" " %d\n", ft->frag_bytes, ft->fraglist_count); *retFrag = newfrag; diff --git a/src/stream/libtcp/tcp_segment_descriptor.cc b/src/stream/libtcp/tcp_segment_descriptor.cc index 3d71fd46b..9b1340701 100644 --- a/src/stream/libtcp/tcp_segment_descriptor.cc +++ b/src/stream/libtcp/tcp_segment_descriptor.cc @@ -70,7 +70,7 @@ uint32_t TcpSegmentDescriptor::init_mss(uint16_t* value) if ( opt.code == TcpOptCode::MAXSEG ) { *value = extract_16bits(opt.data); - DebugFormat(DEBUG_STREAM_STATE, "Found MSS %u\n", *value); + DebugFormat(DEBUG_STREAM_STATE, "Found MSS %hu\n", *value); return TF_MSS; } } diff --git a/src/stream/stream_api.cc b/src/stream/stream_api.cc index b8eebb65a..917657d3f 100644 --- a/src/stream/stream_api.cc +++ b/src/stream/stream_api.cc @@ -834,7 +834,6 @@ TEST_CASE("Stream API", "[stream_api][stream]") { Packet* pkt = get_syn_packet(flow); pkt->flow->session = new TcpSession(flow); - int dir; Stream::stop_inspection(flow, pkt, SSN_DIR_FROM_SERVER, 0, 0); bool ignored = Stream::ignored_session(flow, pkt); @@ -848,7 +847,6 @@ TEST_CASE("Stream API", "[stream_api][stream]") { Packet* pkt = get_syn_ack_packet(flow); pkt->flow->session = new TcpSession(flow); - int dir; Stream::stop_inspection(flow, pkt, SSN_DIR_FROM_SERVER, 0, 0); bool ignored = Stream::ignored_session(flow, pkt); @@ -861,7 +859,6 @@ TEST_CASE("Stream API", "[stream_api][stream]") { Packet* pkt = get_syn_packet(flow); pkt->flow->session = new TcpSession(flow); - int dir; Stream::stop_inspection(flow, pkt, SSN_DIR_FROM_CLIENT, 0, 0); bool ignored = Stream::ignored_session(flow, pkt); @@ -875,7 +872,6 @@ TEST_CASE("Stream API", "[stream_api][stream]") { Packet* pkt = get_syn_ack_packet(flow); pkt->flow->session = new TcpSession(flow); - int dir; Stream::stop_inspection(flow, pkt, SSN_DIR_FROM_CLIENT, 0, 0); bool ignored = Stream::ignored_session(flow, pkt); @@ -888,7 +884,6 @@ TEST_CASE("Stream API", "[stream_api][stream]") { Packet* pkt = get_syn_packet(flow); pkt->flow->session = new TcpSession(flow); - int dir; Stream::stop_inspection(flow, pkt, SSN_DIR_BOTH, 0, 0); bool ignored = Stream::ignored_session(flow, pkt); @@ -902,7 +897,6 @@ TEST_CASE("Stream API", "[stream_api][stream]") { Packet* pkt = get_syn_ack_packet(flow); pkt->flow->session = new TcpSession(flow); - int dir; Stream::stop_inspection(flow, pkt, SSN_DIR_BOTH, 0, 0); bool ignored = Stream::ignored_session(flow, pkt); diff --git a/src/stream/tcp/segment_overlap_editor.cc b/src/stream/tcp/segment_overlap_editor.cc index ff0b10790..2e460439a 100644 --- a/src/stream/tcp/segment_overlap_editor.cc +++ b/src/stream/tcp/segment_overlap_editor.cc @@ -121,7 +121,7 @@ int SegmentOverlapEditor::eval_right() void SegmentOverlapEditor::drop_old_segment() { DebugFormat(DEBUG_STREAM_STATE, - "full right overlap, dropping old segment at seq %d, size %d\n", + "full right overlap, dropping old segment at seq %u, size %hu\n", right->seq, right->payload_size); TcpSegmentNode* drop_seg = right; @@ -219,8 +219,6 @@ int SegmentOverlapEditor::left_overlap_trim_first() int SegmentOverlapEditor::left_overlap_keep_last() { - int rc = STREAM_INSERT_OK; - DebugFormat(DEBUG_STREAM_STATE, "left overlap %d\n", overlap); len = tsd->get_seg_len(); @@ -259,7 +257,7 @@ int SegmentOverlapEditor::left_overlap_keep_last() } } - return rc; + return STREAM_INSERT_OK; } void SegmentOverlapEditor::right_overlap_truncate_existing() diff --git a/src/stream/tcp/tcp_debug_trace.h b/src/stream/tcp/tcp_debug_trace.h index f07dd74ff..4ee2aaa70 100644 --- a/src/stream/tcp/tcp_debug_trace.h +++ b/src/stream/tcp/tcp_debug_trace.h @@ -66,14 +66,14 @@ inline void TraceEvent(const Packet* p, TcpSegmentDescriptor*, uint32_t txd, uin uint32_t rseq = ( txd ) ? h->seq() - txd : h->seq(); uint32_t rack = ( rxd ) ? h->ack() - rxd : h->ack(); - fprintf(stdout, "\n" FMTu64("-3") " %s=0x%02x Seq=%-4u Ack=%-4u Win=%-4u Len=%-4u%s\n", + fprintf(stdout, "\n" FMTu64("-3") " %s=0x%02x Seq=%-4u Ack=%-4u Win=%-4hu Len=%-4hu%s\n", //"\n" FMTu64("-3") " %s=0x%02x Seq=%-4u Ack=%-4u Win=%-4u Len=%-4u End=%-4u%s\n", pc.total_from_daq, flags, h->th_flags, rseq, rack, h->win(), p->dsize, order); } inline void TraceSession(const Flow* lws) { - fprintf(stdout, " LWS: ST=0x%x SF=0x%x CP=%u SP=%u\n", (unsigned)lws->session_state, + fprintf(stdout, " LWS: ST=0x%x SF=0x%x CP=%hu SP=%hu\n", (unsigned)lws->session_state, lws->ssn_state.session_flags, lws->client_port, lws->server_port); } diff --git a/src/stream/tcp/tcp_normalizer.cc b/src/stream/tcp/tcp_normalizer.cc index 97d16df89..54bbcf542 100644 --- a/src/stream/tcp/tcp_normalizer.cc +++ b/src/stream/tcp/tcp_normalizer.cc @@ -309,7 +309,7 @@ int TcpNormalizer::validate_paws_timestamp(TcpSegmentDescriptor& tsd) { /* this packet is from way too far into the future */ DebugFormat(DEBUG_STREAM_STATE, - "packet PAWS timestamp way too far ahead of last packet %ld %d...\n", + "packet PAWS timestamp way too far ahead of last packet %ld %u...\n", tsd.get_pkt()->pkth->ts.tv_sec, peer_tracker->get_ts_last_packet() ); //inc_tcp_discards(); ( ( TcpSession* )tsd.get_flow()->session )->tel.set_tcp_event(EVENT_BAD_TIMESTAMP); diff --git a/src/stream/tcp/tcp_reassembler.cc b/src/stream/tcp/tcp_reassembler.cc index 1ef3214c7..8ae2c14cc 100644 --- a/src/stream/tcp/tcp_reassembler.cc +++ b/src/stream/tcp/tcp_reassembler.cc @@ -222,7 +222,7 @@ int TcpReassembler::add_reassembly_segment(TcpSegmentDescriptor& tsd, int16_t le { // zero size data because of trimming. Don't insert it DebugFormat(DEBUG_STREAM_STATE, "zero size TCP data after left & right trimming " - "(len: %d slide: %d trunc: %d)\n", len, slide, trunc_len); + "(len: %hd slide: %u trunc: %u)\n", len, slide, trunc_len); inc_tcp_discards(); tracker->normalizer->trim_win_payload(tsd); @@ -265,7 +265,7 @@ int TcpReassembler::add_reassembly_segment(TcpSegmentDescriptor& tsd, int16_t le tsd.get_pkt()->packet_flags |= PKT_STREAM_INSERT; DebugFormat(DEBUG_STREAM_STATE, - "added %d bytes on segment list @ seq: 0x%X, total %u, %d segments queued\n", + "added %hu bytes on segment list @ seq: 0x%X, total %u, %u segments queued\n", tsn->payload_size, tsn->seq, seg_bytes_logical, get_pending_segment_count(0)); #ifdef SEG_TEST @@ -287,7 +287,7 @@ int TcpReassembler::dup_reassembly_segment(TcpSegmentNode* left, TcpSegmentNode* queue_reassembly_segment(left, tsn); DebugFormat(DEBUG_STREAM_STATE, - "added %d bytes on segment list @ seq: 0x%X, total %u, %d segments queued\n", + "added %hu bytes on segment list @ seq: 0x%X, total %u, %u segments queued\n", tsn->payload_size, tsn->seq, seg_bytes_logical, get_pending_segment_count(0)); *retSeg = tsn; @@ -343,7 +343,7 @@ int TcpReassembler::purge_to_seq(uint32_t flush_seq) tsn = seglist.head; - DebugFormat(DEBUG_STREAM_STATE, "In purge_to_seq, start seq = 0x%X end seq = 0x%X delta %d\n", + DebugFormat(DEBUG_STREAM_STATE, "In purge_to_seq, start seq = 0x%X end seq = 0x%X delta %u\n", tsn->seq, flush_seq, flush_seq-tsn->seq); while ( tsn ) @@ -561,7 +561,7 @@ int TcpReassembler::flush_data_segments(Packet* p, uint32_t toSeq, uint8_t* flus DEBUG_WRAP(bytes_queued -= bytes_flushed; ); DebugFormat(DEBUG_STREAM_STATE, - "flushed %d bytes / %d segs on stream, %d bytes still queued\n", + "flushed %hu bytes / %u segs on stream, %u bytes still queued\n", bytes_flushed, segs, bytes_queued); return bytes_flushed; @@ -648,7 +648,7 @@ int TcpReassembler::_flush_to_seq(uint32_t bytes, Packet* p, uint32_t pkt_flags) if (footprint == 0) { - DebugFormat(DEBUG_STREAM_STATE, "Negative footprint, bailing %d (0x%X - 0x%X)\n", + DebugFormat(DEBUG_STREAM_STATE, "Negative footprint, bailing %u (0x%X - 0x%X)\n", footprint, stop_seq, seglist_base_seq); return bytes_processed; } @@ -1212,7 +1212,7 @@ void TcpReassembler::insert_segment_in_empty_seglist(TcpSegmentDescriptor& tsd) add_reassembly_segment(tsd, tsd.get_seg_len(), overlap, 0, tsd.get_seg_seq() + overlap, NULL); DebugFormat(DEBUG_STREAM_STATE, - "Attached new queue to seglist, %d bytes queued, base_seq 0x%X\n", + "Attached new queue to seglist, %u bytes queued, base_seq 0x%X\n", tsd.get_seg_len() - overlap, seglist_base_seq); } @@ -1249,7 +1249,7 @@ void TcpReassembler::init_overlap_editor(TcpSegmentDescriptor& tsd) for ( tsn = seglist.head; tsn; tsn = tsn->next ) { DEBUG_WRAP( - DebugFormat(DEBUG_STREAM_STATE, "tsn: %p seq: 0x%X size: %hu delta: %d\n", + DebugFormat(DEBUG_STREAM_STATE, "tsn: %p seq: 0x%X size: %hu delta: %u\n", (void*) tsn, tsn->seq, tsn->payload_size, ( tsn->seq - base_seq ) - last); last = tsn->seq - base_seq; lastptr = tsn; @@ -1272,7 +1272,7 @@ void TcpReassembler::init_overlap_editor(TcpSegmentDescriptor& tsd) for ( tsn = seglist.tail; tsn; tsn = tsn->prev ) { DEBUG_WRAP( - DebugFormat(DEBUG_STREAM_STATE, "tsn: %p seq: 0x%X size: %hu delta: %d\n", + DebugFormat(DEBUG_STREAM_STATE, "tsn: %p seq: 0x%X size: %hu delta: %u\n", (void*) tsn, tsn->seq, tsn->payload_size, ( tsn->seq - base_seq ) - last); last = tsn->seq - base_seq; lastptr = tsn; @@ -1304,11 +1304,11 @@ int TcpReassembler::insert_segment_in_seglist(TcpSegmentDescriptor& tsd) int rc = STREAM_INSERT_OK; DebugFormat(DEBUG_STREAM_STATE, - "Queuing %d bytes on stream!\nbase_seq: %X seq: %X seq_end: %X\n", + "Queuing %u bytes on stream!\nbase_seq: %X seq: %X seq_end: %X\n", tsd.get_end_seq() - tsd.get_seg_seq(), seglist_base_seq, tsd.get_seg_seq(), tsd.get_end_seq()); - DebugFormat(DEBUG_STREAM_STATE, "%d segments on seglist\n", get_pending_segment_count(0)); + DebugFormat(DEBUG_STREAM_STATE, "%u segments on seglist\n", get_pending_segment_count(0)); DebugMessage(DEBUG_STREAM_STATE, "!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+\n"); DebugMessage(DEBUG_STREAM_STATE, "!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+\n"); diff --git a/src/stream/tcp/tcp_session.cc b/src/stream/tcp/tcp_session.cc index e7a50f384..bbca3f2db 100644 --- a/src/stream/tcp/tcp_session.cc +++ b/src/stream/tcp/tcp_session.cc @@ -1107,7 +1107,7 @@ int TcpSession::process(Packet* p) sfip_ntop(p->ptrs.ip_api.get_dst(), dst_addr, sizeof(dst_addr)); DebugFormat((DEBUG_STREAM|DEBUG_STREAM_STATE), - "Got TCP Packet %s:%d -> %s:%d %s\nseq: 0x%X ack:0x%X dsize: %u\n", + "Got TCP Packet %s:%hu -> %s:%hu %s\nseq: 0x%X ack:0x%X dsize: %hu\n", src_addr, p->ptrs.sp, dst_addr, p->ptrs.dp, flagbuf, p->ptrs.tcph->seq(), p->ptrs.tcph->ack(), p->dsize); ); diff --git a/src/target_based/sftarget_reader.cc b/src/target_based/sftarget_reader.cc index 7a0b57c94..368c13164 100644 --- a/src/target_based/sftarget_reader.cc +++ b/src/target_based/sftarget_reader.cc @@ -208,7 +208,7 @@ static void PrintHostAttributeEntry(HostAttributeEntry* host) host->ipAddr.bits); DebugFormat(DEBUG_ATTRIBUTE, - "\tPolicy Information: frag:%s (%u) stream: %s (%u)\n", + "\tPolicy Information: frag:%s (%hhu) stream: %s (%hhu)\n", "look-me-up", host->hostInfo.fragPolicy, "look-me-up", host->hostInfo.streamPolicy); diff --git a/src/time/stopwatch_test.cc b/src/time/stopwatch_test.cc index 140262c7e..b986ec0fa 100644 --- a/src/time/stopwatch_test.cc +++ b/src/time/stopwatch_test.cc @@ -25,7 +25,7 @@ namespace t_stopwatch { -struct Clock : ClockTraits +struct Clock : public ClockTraits { static time_point now() { return time; } diff --git a/tools/snort2lua/preprocessor_states/pps_ftp_telnet_protocol.cc b/tools/snort2lua/preprocessor_states/pps_ftp_telnet_protocol.cc index 38d3931fc..971a85897 100644 --- a/tools/snort2lua/preprocessor_states/pps_ftp_telnet_protocol.cc +++ b/tools/snort2lua/preprocessor_states/pps_ftp_telnet_protocol.cc @@ -46,9 +46,6 @@ private: std::string format; int length; - inline bool operator==(Command c) - { return (!name.compare(c.name)); } - Command() : name(std::string()), format(std::string()), length(command_default_len) { } diff --git a/tools/snort2lua/preprocessor_states/pps_perfmonitor.cc b/tools/snort2lua/preprocessor_states/pps_perfmonitor.cc index 7f0e83d85..ad06777b7 100644 --- a/tools/snort2lua/preprocessor_states/pps_perfmonitor.cc +++ b/tools/snort2lua/preprocessor_states/pps_perfmonitor.cc @@ -38,30 +38,9 @@ public: private: bool output_set = false; - - bool parse_file_option(std::istringstream& data_stream, - std::string orig_name, - std::string option_name, - std::string new_file_name); }; } // namespace -bool PerfMonitor::parse_file_option(std::istringstream& data_stream, - std::string orig_name, - std::string option_name, - std::string new_file_name) -{ - bool tmpval; - - table_api.add_comment(orig_name + " deprecated. If '" + option_name + - " = true', Snort++ automatically prints to '" + new_file_name + "'"); - tmpval = table_api.add_option(option_name, true); - - if (eat_option(data_stream)) // we no longer care about the file name. - return tmpval; - return false; -} - bool PerfMonitor::convert(std::istringstream& data_stream) { std::string keyword; diff --git a/tools/snort2lua/preprocessor_states/pps_sfportscan.cc b/tools/snort2lua/preprocessor_states/pps_sfportscan.cc index 9c08087ad..466883225 100644 --- a/tools/snort2lua/preprocessor_states/pps_sfportscan.cc +++ b/tools/snort2lua/preprocessor_states/pps_sfportscan.cc @@ -36,10 +36,8 @@ public: virtual bool convert(std::istringstream& data_stream); private: - bool parse_list(std::string table_name, std::istringstream& data_stream); bool parse_option(std::string table_name, std::istringstream& data_stream); bool add_portscan_global_option(std::string name, std::istringstream& data_stream); - // a wrapper for parse_list. adds an addition '[..]' around the string bool parse_ip_list(std::string table_name, std::istringstream& data_stream); }; } // namespace @@ -65,20 +63,6 @@ bool PortScan::parse_ip_list(std::string list_name, std::istringstream& data_str return table_api.add_option(list_name, prev); } -bool PortScan::parse_list(std::string list_name, std::istringstream& data_stream) -{ - std::string elem; - bool retval = true; - - if (!(data_stream >> elem) || (elem != "{")) - return false; - - while (data_stream >> elem && elem != "}") - retval && table_api.add_list(list_name, elem) && retval; - - return retval; -} - bool PortScan::parse_option(std::string list_name, std::istringstream& data_stream) { std::string elem; diff --git a/tools/snort2lua/preprocessor_states/pps_smtp.cc b/tools/snort2lua/preprocessor_states/pps_smtp.cc index 817ebf29a..04161fe5b 100644 --- a/tools/snort2lua/preprocessor_states/pps_smtp.cc +++ b/tools/snort2lua/preprocessor_states/pps_smtp.cc @@ -42,9 +42,6 @@ private: std::string format; int length; - inline bool operator==(Command c) - { return (!name.compare(c.name)); } - Command() : name(std::string()), format(std::string()), length(command_default_len) { }