]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #1153 in SNORT/snort3 from ubsan to master
authorMichael Altizer (mialtize) <mialtize@cisco.com>
Thu, 22 Mar 2018 01:31:48 +0000 (21:31 -0400)
committerMichael Altizer (mialtize) <mialtize@cisco.com>
Thu, 22 Mar 2018 01:31:48 +0000 (21:31 -0400)
Squashed commit of the following:

commit 1c7cfc051275c991b96878fdfde0b8851be789eb
Author: Michael Altizer <mialtize@cisco.com>
Date:   Tue Mar 20 18:16:47 2018 -0400

    ips_byte_math: Fix UBSAN left shift of negative value runtime error

commit 849a83586f85a85c8192e7e48aac07cf09e330b5
Author: Michael Altizer <mialtize@cisco.com>
Date:   Tue Mar 20 18:16:26 2018 -0400

    ips_byte_jump: Fix UBSAN left shift of negative value runtime error

commit 51f5501044cd978079c4e41d45cce5e522e3063e
Author: Michael Altizer <mialtize@cisco.com>
Date:   Tue Mar 20 17:49:14 2018 -0400

    hashfcn: Fix UBSAN left shift of negative value runtime error

commit a5cbf457bcdfcdbb532bc36aa353c6baea8241bb
Author: Michael Altizer <mialtize@cisco.com>
Date:   Tue Mar 20 17:07:20 2018 -0400

    parameter: Fix UBSAN shift exponent is too large for 32-bit type runtime error

commit 015abe650696b0be1e18a429e62efc096d228976
Author: Michael Altizer <mialtize@cisco.com>
Date:   Tue Mar 20 16:49:10 2018 -0400

    binder: Fix UBSAN invalid value type runtime error

commit e80d3ffca94a8b508a4e608bc2d90df7a18258cb
Author: Michael Altizer <mialtize@cisco.com>
Date:   Tue Mar 20 16:34:34 2018 -0400

    wizard: Fix UBSAN out-of-bounds access runtime error

commit 540a3cd4973db76f08e12e316727ea2d63d71aad
Author: Michael Altizer <mialtize@cisco.com>
Date:   Tue Mar 20 16:33:35 2018 -0400

    hashfcn: Fix UBSAN integer overflow runtime error

commit 470dc447d63533a784dbfa85e64a39227faffaba
Author: Michael Altizer <mialtize@cisco.com>
Date:   Tue Mar 20 19:22:16 2018 -0400

    extra: Port some CMake options from Snort prime

commit 2dbd95924b68d78104302ec6b62d8ee3e0178760
Author: Michael Altizer <mialtize@cisco.com>
Date:   Tue Mar 20 15:13:50 2018 -0400

    build: Add --enable-ub-sanitizer option for undefined behavior sanitizer

14 files changed:
cmake/configure_options.cmake
cmake/create_options.cmake
configure_cmake.sh
extra/CMakeLists.txt
extra/cmake/CodeCoverage.cmake [new file with mode: 0644]
extra/cmake/configure_options.cmake [new file with mode: 0644]
extra/cmake/create_options.cmake [new file with mode: 0644]
extra/configure_cmake.sh
src/framework/parameter.cc
src/hash/hashfcn.cc
src/ips_options/ips_byte_jump.cc
src/ips_options/ips_byte_math.cc
src/network_inspectors/binder/bind_module.cc
src/service_inspectors/wizard/spells.cc

index b245dce0ebbdddacb1a87e398e1823e5fff37dff..04c1401445dd4becf85cacc8e37c6477a10ce139 100644 (file)
@@ -110,28 +110,49 @@ if ( ENABLE_PROFILE AND CMAKE_COMPILER_IS_GNUCXX )
     set ( DEBUGGING_C_FLAGS "${DEBUGGING_C_FLAGS} -pg" )
 endif ( ENABLE_PROFILE AND CMAKE_COMPILER_IS_GNUCXX )
 
+# ASAN and TSAN are mutually exclusive, so have them absolutely set SANITIZER_*_FLAGS first.
 if ( ENABLE_ADDRESS_SANITIZER )
-    set ( SANITIZER_CXX_FLAGS "-fsanitize=address -fno-omit-frame-pointer" )
-
-    set ( CMAKE_REQUIRED_FLAGS "${SANITIZER_LINKER_FLAGS} -fsanitize=address" )
-    check_cxx_compiler_flag ( "${SANITIZER_CXX_FLAGS}" HAS_SANITIZE_ADDRESS_LDFLAG )
-    if ( HAS_SANITIZE_ADDRESS_LDFLAG )
-        set ( SANITIZER_LINKER_FLAGS "${SANITIZER_LINKER_FLAGS} -fsanitize=address" )
-    endif ()
+    set ( ASAN_CXX_FLAGS "-fsanitize=address -fno-omit-frame-pointer" )
+    set ( ASAN_LINKER_FLAGS "-fsanitize=address" )
+    set ( CMAKE_REQUIRED_FLAGS "${ASAN_LINKER_FLAGS}" )
+    check_cxx_compiler_flag ( "${ASAN_CXX_FLAGS}" HAVE_ADDRESS_SANITIZER )
     unset ( CMAKE_REQUIRED_FLAGS )
+    if ( HAVE_ADDRESS_SANITIZER )
+        set ( SANITIZER_CXX_FLAGS "${ASAN_CXX_FLAGS}" )
+        set ( SANITIZER_LINKER_FLAGS "${ASAN_LINKER_FLAGS}" )
+    else ()
+        message ( SEND_ERROR "Could not enable the address sanitizer!" )
+    endif ()
 endif ( ENABLE_ADDRESS_SANITIZER )
 
 if ( ENABLE_THREAD_SANITIZER )
-    set ( SANITIZER_CXX_FLAGS "-fsanitize=thread -fno-omit-frame-pointer" )
-
-    set ( CMAKE_REQUIRED_FLAGS "${SANITIZER_LINKER_FLAGS} -fsanitize=thread" )
-    check_cxx_compiler_flag ( "${SANITIZER_CXX_FLAGS}" HAS_SANITIZE_THREAD_LDFLAG )
-    if ( HAS_SANITIZE_THREAD_LDFLAG )
-        set ( SANITIZER_LINKER_FLAGS "${SANITIZER_LINKER_FLAGS} -fsanitize=thread" )
-    endif ()
+    set ( TSAN_CXX_FLAGS "-fsanitize=thread -fno-omit-frame-pointer" )
+    set ( TSAN_LINKER_FLAGS "-fsanitize=thread" )
+    set ( CMAKE_REQUIRED_FLAGS "${TSAN_LINKER_FLAGS}" )
+    check_cxx_compiler_flag ( "${TSAN_CXX_FLAGS}" HAVE_THREAD_SANITIZER )
     unset ( CMAKE_REQUIRED_FLAGS )
+    if ( HAVE_THREAD_SANITIZER )
+        set ( SANITIZER_CXX_FLAGS "${TSAN_CXX_FLAGS}" )
+        set ( SANITIZER_LINKER_FLAGS "${TSAN_LINKER_FLAGS}" )
+    else ()
+        message ( SEND_ERROR "Could not enable the thread sanitizer!" )
+    endif ()
 endif ( ENABLE_THREAD_SANITIZER )
 
+if ( ENABLE_UB_SANITIZER )
+    set ( UBSAN_CXX_FLAGS "-fsanitize=undefined -fno-sanitize=alignment -fno-omit-frame-pointer" )
+    set ( UBSAN_LINKER_FLAGS "-fsanitize=undefined -fno-sanitize=alignment" )
+    set ( CMAKE_REQUIRED_FLAGS "${UBSAN_LINKER_FLAGS}" )
+    check_cxx_compiler_flag ( "${UBSAN_CXX_FLAGS}" HAVE_UB_SANITIZER )
+    unset ( CMAKE_REQUIRED_FLAGS )
+    if ( HAVE_UB_SANITIZER )
+        set ( SANITIZER_CXX_FLAGS "${SANITIZER_CXX_FLAGS} ${UBSAN_CXX_FLAGS}" )
+        set ( SANITIZER_LINKER_FLAGS "${SANITIZER_LINKER_FLAGS} ${UBSAN_LINKER_FLAGS}" )
+    else ()
+        message ( SEND_ERROR "Could not enable the undefined behavior sanitizer!" )
+    endif ()
+endif ( ENABLE_UB_SANITIZER )
+
 if ( ENABLE_CODE_COVERAGE )
     include(${CMAKE_MODULE_PATH}/CodeCoverage.cmake)
 endif ( ENABLE_CODE_COVERAGE )
index d88f480efa070296c8bbd7e41e21066ec7fbe92f..5e3eb06dbb7e74d46903e3609de94340225d16fb 100644 (file)
@@ -41,6 +41,7 @@ option ( ENABLE_GDB "Enable gdb debugging information" ON )
 option ( ENABLE_PROFILE "Enable profiling options (developers only)" OFF )
 option ( ENABLE_ADDRESS_SANITIZER "enable address sanitizer support" OFF )
 option ( ENABLE_THREAD_SANITIZER "enable thread sanitizer support" OFF )
+option ( ENABLE_UB_SANITIZER "enable undefined behavior sanitizer support" OFF )
 option ( ENABLE_CODE_COVERAGE "Whether to enable code coverage support" OFF )
 
 # signals
index 52bef51f9e0cb2a1c20be82709d163ef10005c7c..d42a23836f2b71114813016a9457b17386349d6f 100755 (executable)
@@ -1,6 +1,7 @@
 #!/bin/sh
 # Convenience wrapper for easily viewing/setting options that
 # the project's CMake scripts will recognize
+
 set -e
 command="$0 $*"
 
@@ -53,6 +54,8 @@ Optional Features:
                             enable address sanitizer support
     --enable-thread-sanitizer
                             enable thread sanitizer support
+    --enable-ub-sanitizer
+                            enable undefined behavior sanitizer support
     --enable-unit-tests     build unit tests
     --enable-piglet         build piglet test harness
     --disable-static-daq    link static DAQ modules
@@ -117,20 +120,6 @@ append_cache_entry () {
     CMakeCacheEntries="$CMakeCacheEntries -D $1:$2=$3"
 }
 
-check_and_append_cache_entry() {
-    if [ -f $3 ]; then
-        append_cache_entry $1 $2 $3
-    else 
-        echo ""
-        echo "the $1 variable, which is specified using a --with-* options,"
-        echo "requires an absolute path to the library.  Could not stat the"
-        echo "the library:"
-        echo "    $3"
-        echo ""
-        exit 1
-    fi
-}
-
 # set defaults
 builddir=build
 prefix=/usr/local/snort
@@ -283,6 +272,12 @@ while [ $# -ne 0 ]; do
         --disable-thread-sanitizer)
             append_cache_entry ENABLE_THREAD_SANITIZER  BOOL false
             ;;
+        --enable-ub-sanitizer)
+            append_cache_entry ENABLE_UB_SANITIZER  BOOL true
+            ;;
+        --disable-ub-sanitizer)
+            append_cache_entry ENABLE_UB_SANITIZER  BOOL false
+            ;;
         --enable-unit-tests)
             append_cache_entry ENABLE_UNIT_TESTS        BOOL true
             ;;
index be3589b025f9d65211fa5b1c2c113d83426d364e..05fc5074434605f6169fb36d085af096c803c34b 100644 (file)
@@ -4,6 +4,7 @@ project( snort_extra CXX C )
 set (EXTRA_VERSION_MAJOR 1)
 set (EXTRA_VERSION_MINOR 0)
 set (EXTRA_VERSION_PATCH 0)
+set (EXTRA_VERSION "${EXTRA_VERSION_MAJOR}.${EXTRA_VERSION_MINOR}.${EXTRA_VERSION_PATCH}")
 
 set (CMAKE_CXX_STANDARD 11)
 set (CMAKE_CXX_STANDARD_REQUIRED ON)
@@ -13,8 +14,11 @@ set (CMAKE_C_STANDARD 99)
 set (CMAKE_C_STANDARD_REQUIRED ON)
 set (CMAKE_C_EXTENSIONS ON)
 
+set (CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
 # Pull in definitions of various install directories
 include (GNUInstallDirs)
+include (${CMAKE_MODULE_PATH}/create_options.cmake)
+include (${CMAKE_MODULE_PATH}/configure_options.cmake)
 
 set (CPACK_GENERATOR TGZ)
 set (CPACK_PACKAGE_NAME "snort_extra")
@@ -75,4 +79,30 @@ foreach ( OPT ${CPP_OPTS_OTHER} )
     set ( ${OPT}_CPPFLAGS "${CPPFLAGS}" CACHE STRING "" )
 endforeach ( OPT )
 
+# Set these after all tests are done but *before* any subdirectories are included
+#  or other targets declared.
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_C_FLAGS}")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CXX_FLAGS}")
+set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${EXTRA_LINKER_FLAGS}")
+set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${EXTRA_LINKER_FLAGS}")
+foreach (EXTRA_LIBRARY IN LISTS EXTRA_LIBRARIES)
+    link_libraries(${EXTRA_LIBRARY})
+endforeach (EXTRA_LIBRARY)
+
 add_subdirectory ( src )
+
+message("
+-------------------------------------------------------
+${CMAKE_PROJECT_NAME} version ${EXTRA_VERSION}
+
+Install options:
+    prefix:     ${CMAKE_INSTALL_PREFIX}
+
+Compiler options:
+    CC:             ${CMAKE_C_COMPILER}
+    CXX:            ${CMAKE_CXX_COMPILER}
+    CFLAGS:         ${CMAKE_C_FLAGS}
+    CXXFLAGS:       ${CMAKE_CXX_FLAGS}
+    EXE_LDFLAGS:    ${CMAKE_EXE_LINKER_FLAGS}
+    MODULE_LDFLAGS: ${CMAKE_MODULE_LINKER_FLAGS}
+")
diff --git a/extra/cmake/CodeCoverage.cmake b/extra/cmake/CodeCoverage.cmake
new file mode 100644 (file)
index 0000000..1bf764d
--- /dev/null
@@ -0,0 +1,36 @@
+#
+# Loosely based on:
+#   https://raw.githubusercontent.com/peti/autoconf-archive/master/m4/ax_code_coverage.m4
+#       - and -
+#   https://raw.githubusercontent.com/bilke/cmake-modules/master/CodeCoverage.cmake
+#
+
+find_program( GCOV_PATH gcov )
+
+if(NOT GCOV_PATH)
+    message(FATAL_ERROR "gcov not found! Aborting...")
+endif()
+
+if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(Apple)?[Cc]lang")
+    if("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS 3)
+        message(FATAL_ERROR "Clang version must be 3.0.0 or greater! Aborting...")
+    endif()
+elseif(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
+    message(FATAL_ERROR "Compiler is not GNU gcc! Aborting...")
+endif()
+
+set(COVERAGE_COMPILER_FLAGS "-O0 -g -fprofile-arcs -ftest-coverage")
+
+if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
+    set(COVERAGE_LINKER_FLAGS "")
+    set(COVERAGE_LIBRARIES "gcov")
+else()
+    set(COVERAGE_LINKER_FLAGS "--coverage")
+    set(COVERAGE_LIBRARIES "")
+endif()
+
+mark_as_advanced(
+    COVERAGE_COMPILER_FLAGS
+    COVERAGE_LINKER_FLAGS
+    COVERAGE_LIBRARIES
+)
diff --git a/extra/cmake/configure_options.cmake b/extra/cmake/configure_options.cmake
new file mode 100644 (file)
index 0000000..a0c605b
--- /dev/null
@@ -0,0 +1,80 @@
+# map cmake options to compiler defines and do miscellaneous further configuration work
+# cmake options are defined in cmake/create_options.cmake
+
+include(CheckCXXCompilerFlag)
+
+# debugging
+
+if ( ENABLE_DEBUG )
+    set ( DEBUGGING_C_FLAGS "${DEBUGGING_C_FLAGS} -g -DDEBUG" )
+endif ( ENABLE_DEBUG )
+
+if ( ENABLE_GDB )
+    set ( DEBUGGING_C_FLAGS "${DEBUGGING_C_FLAGS} -g -ggdb" )
+endif ( ENABLE_GDB )
+
+# ASAN and TSAN are mutually exclusive, so have them absolutely set SANITIZER_*_FLAGS first.
+if ( ENABLE_ADDRESS_SANITIZER )
+    set ( ASAN_CXX_FLAGS "-fsanitize=address -fno-omit-frame-pointer" )
+    set ( ASAN_LINKER_FLAGS "-fsanitize=address" )
+    set ( CMAKE_REQUIRED_FLAGS "${ASAN_LINKER_FLAGS}" )
+    check_cxx_compiler_flag ( "${ASAN_CXX_FLAGS}" HAVE_ADDRESS_SANITIZER )
+    unset ( CMAKE_REQUIRED_FLAGS )
+    if ( HAVE_ADDRESS_SANITIZER )
+        set ( SANITIZER_CXX_FLAGS "${ASAN_CXX_FLAGS}" )
+        set ( SANITIZER_LINKER_FLAGS "${ASAN_LINKER_FLAGS}" )
+    else ()
+        message ( SEND_ERROR "Could not enable the address sanitizer!" )
+    endif ()
+endif ( ENABLE_ADDRESS_SANITIZER )
+
+if ( ENABLE_THREAD_SANITIZER )
+    set ( TSAN_CXX_FLAGS "-fsanitize=thread -fno-omit-frame-pointer" )
+    set ( TSAN_LINKER_FLAGS "-fsanitize=thread" )
+    set ( CMAKE_REQUIRED_FLAGS "${TSAN_LINKER_FLAGS}" )
+    check_cxx_compiler_flag ( "${TSAN_CXX_FLAGS}" HAVE_THREAD_SANITIZER )
+    unset ( CMAKE_REQUIRED_FLAGS )
+    if ( HAVE_THREAD_SANITIZER )
+        set ( SANITIZER_CXX_FLAGS "${TSAN_CXX_FLAGS}" )
+        set ( SANITIZER_LINKER_FLAGS "${TSAN_LINKER_FLAGS}" )
+    else ()
+        message ( SEND_ERROR "Could not enable the thread sanitizer!" )
+    endif ()
+endif ( ENABLE_THREAD_SANITIZER )
+
+if ( ENABLE_UB_SANITIZER )
+    set ( UBSAN_CXX_FLAGS "-fsanitize=undefined -fno-sanitize=alignment -fno-omit-frame-pointer" )
+    set ( UBSAN_LINKER_FLAGS "-fsanitize=undefined -fno-sanitize=alignment" )
+    set ( CMAKE_REQUIRED_FLAGS "${UBSAN_LINKER_FLAGS}" )
+    check_cxx_compiler_flag ( "${UBSAN_CXX_FLAGS}" HAVE_UB_SANITIZER )
+    unset ( CMAKE_REQUIRED_FLAGS )
+    if ( HAVE_UB_SANITIZER )
+        set ( SANITIZER_CXX_FLAGS "${SANITIZER_CXX_FLAGS} ${UBSAN_CXX_FLAGS}" )
+        set ( SANITIZER_LINKER_FLAGS "${SANITIZER_LINKER_FLAGS} ${UBSAN_LINKER_FLAGS}" )
+    else ()
+        message ( SEND_ERROR "Could not enable the undefined behavior sanitizer!" )
+    endif ()
+endif ( ENABLE_UB_SANITIZER )
+
+if ( ENABLE_CODE_COVERAGE )
+    include(${CMAKE_MODULE_PATH}/CodeCoverage.cmake)
+endif ( ENABLE_CODE_COVERAGE )
+
+
+# Accumulate extra flags and libraries
+#[[
+message("
+    DEBUGGING_C_FLAGS = ${DEBUGGING_C_FLAGS}
+    SANITIZER_CXX_FLAGS = ${SANITIZER_CXX_FLAGS}
+    SANITIZER_LINKER_FLAGS = ${SANITIZER_LINKER_FLAGS}
+    COVERAGE_COMPILER_FLAGS = ${COVERAGE_COMPILER_FLAGS}
+    COVERAGE_LINKER_FLAGS = ${COVERAGE_LINKER_FLAGS}
+    COVERAGE_LIBRARIES = ${COVERAGE_LIBRARIES}
+")
+]]
+set ( EXTRA_C_FLAGS "${EXTRA_C_FLAGS} ${HARDENED_CXX_FLAGS} ${DEBUGGING_C_FLAGS} ${SANITIZER_CXX_FLAGS} ${COVERAGE_COMPILER_FLAGS}" )
+set ( EXTRA_CXX_FLAGS "${EXTRA_CXX_FLAGS} ${HARDENED_CXX_FLAGS} ${DEBUGGING_C_FLAGS} ${SANITIZER_CXX_FLAGS} ${COVERAGE_COMPILER_FLAGS}" )
+set ( EXTRA_LINKER_FLAGS "${EXTRA_LINKER_FLAGS} ${HARDENED_LINKER_FLAGS} ${SANITIZER_LINKER_FLAGS} ${COVERAGE_LINKER_FLAGS}" )
+foreach (EXTRA_LIBRARY IN LISTS COVERAGE_LIBRARIES)
+    list ( APPEND EXTRA_LIBRARIES ${EXTRA_LIBRARY} )
+endforeach ()
diff --git a/extra/cmake/create_options.cmake b/extra/cmake/create_options.cmake
new file mode 100644 (file)
index 0000000..69d6c69
--- /dev/null
@@ -0,0 +1,15 @@
+#  All of the possible user options.  All of these options will show up
+#  in the CACHE.  If you'd like to change one of these values,
+#  use `ccmake ${PATH_TO_SOURCE}`.
+#  Alternatively, you can pass them to cmake on the command line using
+#  the '-D' flag:
+#      cmake -DENABLE_FOO=ON -DCMAKE_INSTALL_PREFIX=/my/install/path $cmake_src_path
+
+# debugging
+option ( ENABLE_DEBUG "Enable debugging options (bugreports and developers only)" OFF )
+option ( ENABLE_GDB "Enable gdb debugging information" ON )
+option ( ENABLE_ADDRESS_SANITIZER "enable address sanitizer support" OFF )
+option ( ENABLE_THREAD_SANITIZER "enable thread sanitizer support" OFF )
+option ( ENABLE_UB_SANITIZER "enable undefined behavior sanitizer support" OFF )
+option ( ENABLE_CODE_COVERAGE "Whether to enable code coverage support" OFF )
+
index f201ea62c1b448c40f8453a742f3a945324c636e..96b45aa084225ea3e74011b0139753be287b447c 100755 (executable)
@@ -20,6 +20,20 @@ Usage: $0 [OPTION]... [VAR=VALUE]...
         --builddir=   The build directory
         --generator=  run cmake --help for a list of generators
         --prefix=     Snort++ installation prefix
+
+Optional Features:
+    --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
+    --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
+    --enable-code-coverage  Whether to enable code coverage support
+    --enable-debug          enable debugging options (bugreports and developers
+                            only)
+    --disable-gdb           disable gdb debugging information
+    --enable-address-sanitizer
+                            enable address sanitizer support
+    --enable-thread-sanitizer
+                            enable thread sanitizer support
+    --enable-ub-sanitizer
+                            enable undefined behavior sanitizer support
 "
 
 sourcedir="$( cd "$( dirname "$0" )" && pwd )"
@@ -55,6 +69,9 @@ while [ $# -ne 0 ]; do
         --builddir=*)
             builddir=$optarg
             ;;
+        --define=*)
+            CMakeCacheEntries="$CMakeCacheEntries -D$optarg"
+            ;;
         --generator=*)
             CMakeGenerator="$optarg"
             ;;
@@ -62,6 +79,42 @@ while [ $# -ne 0 ]; do
             prefix=$optarg
             append_cache_entry CMAKE_INSTALL_PREFIX PATH $optarg
             ;;
+        --enable-code-coverage)
+            append_cache_entry ENABLE_CODE_COVERAGE     BOOL true
+            ;;
+        --disable-code-coverage)
+            append_cache_entry ENABLE_CODE_COVERAGE     BOOL false
+            ;;
+        --enable-debug)
+            append_cache_entry ENABLE_DEBUG             BOOL true
+            ;;
+        --disable-debug)
+            append_cache_entry ENABLE_DEBUG             BOOL false
+            ;;
+        --enable-gdb)
+            append_cache_entry ENABLE_GDB               BOOL true
+            ;;
+        --disable-gdb)
+            append_cache_entry ENABLE_GDB               BOOL false
+            ;;
+        --enable-address-sanitizer)
+            append_cache_entry ENABLE_ADDRESS_SANITIZER BOOL true
+            ;;
+        --disable-address-sanitizer)
+            append_cache_entry ENABLE_ADDRESS_SANITIZER BOOL false
+            ;;
+        --enable-thread-sanitizer)
+            append_cache_entry ENABLE_THREAD_SANITIZER  BOOL true
+            ;;
+        --disable-thread-sanitizer)
+            append_cache_entry ENABLE_THREAD_SANITIZER  BOOL false
+            ;;
+        --enable-ub-sanitizer)
+            append_cache_entry ENABLE_UB_SANITIZER  BOOL true
+            ;;
+        --disable-ub-sanitizer)
+            append_cache_entry ENABLE_UB_SANITIZER  BOOL false
+            ;;
         *)
             echo "Invalid option '$1'.  Try $0 --help to see available options."
             exit 1
index f5a02e8b701ca1c582a7103353d3134486793d1d..5e0d1a3789060c6ea87bd9af0eb385dd9851d38a 100644 (file)
@@ -253,7 +253,7 @@ static bool valid_multi(Value& v, const char* r)
     vector<string> list;
     split(s, list);
 
-    unsigned mask = 0;
+    unsigned long long mask = 0;
 
     for ( const auto& p : list )
     {
@@ -264,7 +264,7 @@ static bool valid_multi(Value& v, const char* r)
         unsigned idx = get_index(r, t);
 
         if ( idx < Value::mask_bits )
-            mask |= (1 << idx);
+            mask |= (1ULL << idx);
     }
     v.set_aux(mask);
     return true;
index cdf7c8a3833999fb03ba38cf9244f84f4a0643fb..3316793521738278097d4f6ec70e87244be4f981 100644 (file)
@@ -63,7 +63,7 @@ HashFnc* hashfcn_new(int m)
     {
         p->seed     = nearest_prime( (rand()%m)+3191);
         p->scale    = nearest_prime( (rand()%m)+709);
-        p->hardener = (rand()*rand()) + 133824503;
+        p->hardener = ((unsigned) rand() * rand()) + 133824503;
     }
 
     p->hash_fcn   = &hashfcn_hash;
@@ -133,7 +133,7 @@ void mix_str(
 
         for (unsigned l=0; l<k; l++)
         {
-            tmp |= s[i + l] << l*8;
+            tmp |= (unsigned char) s[i + l] << l*8;
         }
 
         switch (j)
index 9e7cec22e1127defeafcb11a9f54ee4b3f188e7a..168a8f6d2d44749898a879407bef9c37ba4833be 100644 (file)
@@ -160,7 +160,7 @@ uint32_t ByteJumpOption::hash() const
     mix(a,b,c);
 
     a += data->post_offset;
-    b += data->from_end_flag << 16 | data->offset_var << 8 | data->post_offset_var;
+    b += data->from_end_flag << 16 | (uint32_t) data->offset_var << 8 | data->post_offset_var;
     c += data->bitmask_val;
 
     mix(a,b,c);
index 4c4821c89dd5652a5f1dfa6a6359f57cc4413149..14456db74882926621f2ae50ec912ea25777bbf8 100644 (file)
@@ -110,9 +110,9 @@ uint32_t ByteMathOption::hash() const
     mix(a,b,c);
 
     a += data->offset;
-    b += (data->rvalue_var << 24 |
-        data->offset_var << 16 |
-        data->result_var << 8 |
+    b += ((uint32_t) data->rvalue_var << 24 |
+        (uint32_t) data->offset_var << 16 |
+        (uint32_t) data->result_var << 8 |
         data->endianess);
     c += data->base;
 
index 89dff5f3144e7843867cf1c8cab2a990c4b4c3bd..4fe3495208252c5010449b50ccc0d1c63075237f 100644 (file)
@@ -281,6 +281,7 @@ bool BinderModule::begin(const char* fqn, int idx, SnortConfig*)
     {
         work = new Binding;
         unsplit_nets = false;
+        unsplit_ports = false;
         use_name_count = 0;
         use_type_count = 0;
     }
index 001fc6e819959d1d5f8c42f0229db73df3d338b7..da783ec175b708ced96d257014156b94d48f370f 100644 (file)
@@ -94,6 +94,7 @@ bool SpellBook::add_spell(const char* key, const char* val)
     unsigned i = 0;
     MagicPage* p = root;
 
+    // Perform a longest prefix match before inserting the pattern.
     while ( i < hv.size() )
     {
         int c = toupper(hv[i]);
@@ -101,7 +102,7 @@ bool SpellBook::add_spell(const char* key, const char* val)
         if ( c == WILD && p->any )
             p = p->any;
 
-        else if ( p->next[c] )
+        else if ( c != WILD && p->next[c] )
             p = p->next[c];
 
         else