From: Mike Stepanek (mstepane) Date: Thu, 10 Jan 2019 18:16:17 +0000 (-0500) Subject: Merge pull request #1470 in SNORT/snort3 from ~PSHINDE2/snort3:lua_detector_crash... X-Git-Tag: 3.0.0-251~68 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fcd4ca7bac9d20120ffb1058488bc8e42a17dffc;p=thirdparty%2Fsnort3.git Merge pull request #1470 in SNORT/snort3 from ~PSHINDE2/snort3:lua_detector_crash to master Squashed commit of the following: commit 5ec05000ce2d077cf9482ef8f5ff3c32ff72d3b7 Author: Devendra Dahiphale Date: Thu Jan 10 13:15:10 2019 -0500 config: Use basename_r() function for FreeBSD versions < 12.0.0 --- diff --git a/cmake/sanity_checks.cmake b/cmake/sanity_checks.cmake index 4d9822f70..333c23573 100644 --- a/cmake/sanity_checks.cmake +++ b/cmake/sanity_checks.cmake @@ -17,6 +17,7 @@ check_function_exists(mallinfo HAVE_MALLINFO) check_function_exists(malloc_trim HAVE_MALLOC_TRIM) check_function_exists(memrchr HAVE_MEMRCHR) check_function_exists(sigaction HAVE_SIGACTION) +check_function_exists(basename_r HAVE_BASENAME_R) check_cxx_source_compiles( " diff --git a/config.cmake.h.in b/config.cmake.h.in index 7066c299a..98cbb6c98 100644 --- a/config.cmake.h.in +++ b/config.cmake.h.in @@ -155,6 +155,8 @@ /* Define to 1 if you have the GNU form of the `strerror_r' function. */ #cmakedefine HAVE_GNU_STRERROR_R 1 +/* Define 1 if you have basename_r function for freebsd < 12.0.0 */ +#cmakedefine HAVE_BASENAME_R 1 /* Available compiler options */ diff --git a/src/network_inspectors/appid/lua_detector_module.cc b/src/network_inspectors/appid/lua_detector_module.cc index b6a9ef6ca..19c300c9a 100644 --- a/src/network_inspectors/appid/lua_detector_module.cc +++ b/src/network_inspectors/appid/lua_detector_module.cc @@ -369,8 +369,14 @@ void LuaDetectorManager::load_detector(char* detector_filename, bool isCustom) // Alternatively, conflicts between reload may be avoided if a new lua state is // created separately, then swapped and free old state. char detectorName[MAX_LUA_DETECTOR_FILENAME_LEN]; +#ifdef HAVE_BASENAME_R + char detector_res[MAX_LUA_DETECTOR_FILENAME_LEN]; + snprintf(detectorName, MAX_LUA_DETECTOR_FILENAME_LEN, "%s_%s", + (isCustom ? "custom" : "odp"), basename_r(detector_filename, detector_res)); +#else snprintf(detectorName, MAX_LUA_DETECTOR_FILENAME_LEN, "%s_%s", (isCustom ? "custom" : "odp"), basename(detector_filename)); +#endif // create a new function environment and store it in the registry lua_newtable(L); // create _ENV tables