]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Pull request #3256: config_parser: fix segfault when include(nil)
authorMike Stepanek (mstepane) <mstepane@cisco.com>
Mon, 7 Feb 2022 14:05:25 +0000 (14:05 +0000)
committerMike Stepanek (mstepane) <mstepane@cisco.com>
Mon, 7 Feb 2022 14:05:25 +0000 (14:05 +0000)
Merge in SNORT/snort3 from ~VHORBAN/snort3:fix_segv_in_config_parser_lua to master

Squashed commit of the following:

commit 692843214a9428cd00ea99696dbfe755281f8a03
Author: Volodymyr Horban <vhorban@cisco.com>
Date:   Mon Jan 31 15:05:04 2022 +0200

    main: stop with error on include(nil) attempt

src/main/bootstrap.lua
src/parser/parse_conf.cc

index 3afcb10d5c3b4c0e9bd7cb58ec0d11a0296897ba..4c0ff103f91fdcc6ad6a6aac5a07da9d4dda55a9 100644 (file)
@@ -89,6 +89,10 @@ function path_top()
 end
 
 function include(file)
+    if ( file == nil ) then
+        error("include nil file", 2)
+    end
+
     local cname = ffi.C.push_include_path(file)
     local fname = ffi.string(cname);
     path_push(fname)
index f9c73e209f70ac32e714e77475178cca4f2a9a5f..c867565788a87ed7b22191449231a76d9568a562 100644 (file)
@@ -160,6 +160,8 @@ static bool relative_to_include_dir(const char* file, std::string& path)
 
 const char* get_config_file(const char* arg, std::string& file)
 {
+    assert(arg);
+
     bool absolute = (arg[0] == '/');
 
     if ( absolute )