]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #1470 in SNORT/snort3 from ~PSHINDE2/snort3:lua_detector_crash...
authorMike Stepanek (mstepane) <mstepane@cisco.com>
Thu, 10 Jan 2019 18:16:17 +0000 (13:16 -0500)
committerMike Stepanek (mstepane) <mstepane@cisco.com>
Thu, 10 Jan 2019 18:16:17 +0000 (13:16 -0500)
Squashed commit of the following:

commit 5ec05000ce2d077cf9482ef8f5ff3c32ff72d3b7
Author: Devendra Dahiphale <ddahipha@cisco.com>
Date:   Thu Jan 10 13:15:10 2019 -0500

    config: Use basename_r() function for FreeBSD versions < 12.0.0

cmake/sanity_checks.cmake
config.cmake.h.in
src/network_inspectors/appid/lua_detector_module.cc

index 4d9822f70a75fb059267d3326d2b6b2728e7f1b2..333c23573fe416498709db6be6fd4bddf7a92440 100644 (file)
@@ -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(
     "
index 7066c299a518ecd781a294e0e3d8e9601f3f04cf..98cbb6c98328bbdc44bc621fbd77f7e81a67271e 100644 (file)
 /* 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 */
 
index b6a9ef6cac17cd67340fb8990aa3fbef51ec4e44..19c300c9aaaf0d0dc85851407d4f3d18c6a20f67 100644 (file)
@@ -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