From: Michael Altizer (mialtize) Date: Sat, 7 Sep 2019 14:31:14 +0000 (-0400) Subject: Merge pull request #1737 in SNORT/snort3 from ~MIALTIZE/snort3:unversioned_safec... X-Git-Tag: 3.0.0-261~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=051f536021ebe972e0b1eb1907cb996d28bf1189;p=thirdparty%2Fsnort3.git Merge pull request #1737 in SNORT/snort3 from ~MIALTIZE/snort3:unversioned_safec to master Squashed commit of the following: commit 08aa510f3ae6d74ebd81023b0ef2ecf480d92c9d Author: Michael Altizer Date: Fri Sep 6 11:55:17 2019 -0400 safec: Update CMake logic for unversioned LibSafeC pkg-config name Thanks to Noah Dietrich for reporting the issue. --- diff --git a/cmake/FindSafeC.cmake b/cmake/FindSafeC.cmake index a91323a54..55f1c22bd 100644 --- a/cmake/FindSafeC.cmake +++ b/cmake/FindSafeC.cmake @@ -1,31 +1,25 @@ find_package(PkgConfig) +pkg_check_modules(PC_SAFEC libsafec) -# LibSafeC is currently incompatible with Clang - https://github.com/rurban/safeclib/issues/58 -if (PKG_CONFIG_EXECUTABLE AND NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --list-all - OUTPUT_VARIABLE _pkgconfig_list_result - OUTPUT_STRIP_TRAILING_WHITESPACE) - string(REGEX MATCH "safec-([0-9]+\.[0-9])+" MATCHED ${_pkgconfig_list_result}) - if (MATCHED) - set(SAFEC_VERSION ${CMAKE_MATCH_1}) - pkg_check_modules(PC_SAFEC safec-${SAFEC_VERSION}) - - find_path(SAFEC_INCLUDE_DIR - NAMES libsafec/safe_lib.h - HINTS ${PC_SAFEC_INCLUDEDIR} ${PC_SAFEC_INCLUDEDIRS} - NO_SYSTEM_ENVIRONMENT_PATH - ) - find_library(SAFEC_LIBRARIES - NAMES safec-${SAFEC_VERSION} - HINTS ${PC_SAFEC_LIBDIR} ${PC-SAFEC_LIBRARY_DIRS} - ) - endif() -endif() +find_path(SAFEC_INCLUDE_DIR + NAMES safe_lib.h + HINTS ${PC_SAFEC_INCLUDEDIR} ${PC_SAFEC_INCLUDE_DIRS} + NO_SYSTEM_ENVIRONMENT_PATH +) +find_library(SAFEC_LIBRARIES + NAMES ${PC_SAFEC_LIBRARIES} + HINTS ${PC_SAFEC_LIBDIR} ${PC_SAFEC_LIBRARY_DIRS} +) include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(SafeC - REQUIRED_VARS SAFEC_INCLUDE_DIR SAFEC_LIBRARIES +find_package_handle_standard_args( + SafeC + REQUIRED_VARS + SAFEC_INCLUDE_DIR + SAFEC_LIBRARIES + VERSION_VAR + PC_SAFEC_VERSION ) mark_as_advanced( diff --git a/cmake/configure_options.cmake b/cmake/configure_options.cmake index ca2b3e3a0..bff6cd806 100644 --- a/cmake/configure_options.cmake +++ b/cmake/configure_options.cmake @@ -94,10 +94,6 @@ if ( ENABLE_PIE ) endif () endif ( ENABLE_PIE ) -if ( ENABLE_SAFEC ) - set(ENABLE_SAFEC "1") -endif ( ENABLE_SAFEC ) - # debugging set ( DEBUG_MSGS ${ENABLE_DEBUG_MSGS} ) diff --git a/configure_cmake.sh b/configure_cmake.sh index 7a01cf462..197a24336 100755 --- a/configure_cmake.sh +++ b/configure_cmake.sh @@ -27,7 +27,7 @@ Optional Features: --enable-code-coverage Whether to enable code coverage support --enable-hardened-build Detect and use compile-time hardening options --enable-pie Attempt to produce a position-independent executable - --disable-safec do not use libsafec bounds checking even if available + --disable-safec do not use libsafec bounds checking even if available --disable-static-ips-actions do not include ips actions in binary --disable-static-inspectors diff --git a/doc/tutorial.txt b/doc/tutorial.txt index 7a3c5a951..b8537c042 100644 --- a/doc/tutorial.txt +++ b/doc/tutorial.txt @@ -56,7 +56,7 @@ Optional: * lzma >= 5.1.2 from http://tukaani.org/xz/ for decompression of SWF and PDF files -* safec from https://github.com/rurban/safeclib/ for runtime bounds +* safec >= 3.5 from https://github.com/rurban/safeclib/ for runtime bounds checks on certain legacy C-library calls * source-highlight from http://www.gnu.org/software/src-highlite/ to diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 327c512b2..779aa3fd2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -12,7 +12,6 @@ set(EXTERNAL_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY} ${PCAP_LIBRARIES} ${PCRE_LIBRARIES} - ${SAFEC_LIBRARIES} ${UUID_LIBRARY} ${ZLIB_LIBRARIES} ) @@ -24,7 +23,6 @@ set(EXTERNAL_INCLUDES ${OPENSSL_INCLUDE_DIR} ${PCAP_INCLUDE_DIR} ${PCRE_INCLUDE_DIR} - ${SAFEC_INCLUDE_DIR} ${UUID_INCLUDE_DIR} ${ZLIB_INCLUDE_DIRS} ) @@ -38,6 +36,11 @@ if ( HS_FOUND ) LIST(APPEND EXTERNAL_INCLUDES ${HS_INCLUDE_DIRS}) endif () +if ( HAVE_SAFEC ) + LIST(APPEND EXTERNAL_LIBRARIES ${SAFEC_LIBRARIES}) + LIST(APPEND EXTERNAL_INCLUDES ${SAFEC_INCLUDE_DIR}) +endif () + if ( ICONV_FOUND ) LIST(APPEND EXTERNAL_LIBRARIES ${ICONV_LIBRARY}) LIST(APPEND EXTERNAL_INCLUDES ${ICONV_INCLUDE_DIR}) diff --git a/src/utils/safec.h b/src/utils/safec.h index 0311cef00..e2a714b47 100644 --- a/src/utils/safec.h +++ b/src/utils/safec.h @@ -24,8 +24,8 @@ extern "C" { -#include -#include +#include +#include } #else