From: Mike Stepanek (mstepane) Date: Mon, 7 Feb 2022 14:05:25 +0000 (+0000) Subject: Pull request #3256: config_parser: fix segfault when include(nil) X-Git-Tag: 3.1.23.0~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ca634c21872055ba03ad67670449c7e59a831684;p=thirdparty%2Fsnort3.git Pull request #3256: config_parser: fix segfault when include(nil) 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 Date: Mon Jan 31 15:05:04 2022 +0200 main: stop with error on include(nil) attempt --- diff --git a/src/main/bootstrap.lua b/src/main/bootstrap.lua index 3afcb10d5..4c0ff103f 100644 --- a/src/main/bootstrap.lua +++ b/src/main/bootstrap.lua @@ -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) diff --git a/src/parser/parse_conf.cc b/src/parser/parse_conf.cc index f9c73e209..c86756578 100644 --- a/src/parser/parse_conf.cc +++ b/src/parser/parse_conf.cc @@ -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 )