From: Michael Altizer (mialtize) Date: Wed, 30 May 2018 15:57:24 +0000 (-0400) Subject: Merge pull request #1241 in SNORT/snort3 from fix_snort2lua_crash to master X-Git-Tag: 3.0.0-246~77 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=80a74adb20213fdbbf91213c2e46c36c3f8cd39f;p=thirdparty%2Fsnort3.git Merge pull request #1241 in SNORT/snort3 from fix_snort2lua_crash to master Squashed commit of the following: commit a28c2bb97c2431484abfc120dcabc03b7e8b1ebe Author: Carter Waxman Date: Fri May 25 14:45:15 2018 -0400 snort2lua: don't try to index into empty lines --- diff --git a/tools/snort2lua/helpers/converter.cc b/tools/snort2lua/helpers/converter.cc index 2ee0f47f9..66b65a7b3 100644 --- a/tools/snort2lua/helpers/converter.cc +++ b/tools/snort2lua/helpers/converter.cc @@ -212,10 +212,14 @@ int Converter::parse_file( data_api.set_current_file(input_file); //Set at each line to handle recursion correctly data_api.set_current_line(++line_num); - std::size_t first_non_white_char = tmp.find_first_not_of(' '); + if ( tmp.empty() ) + continue; + + // same critea used for rtrim + // http://en.cppreference.com/w/cpp/string/byte/isspace + std::size_t first_non_white_char = tmp.find_first_not_of(" \f\n\r\t\v"); - // no, i did not know that semicolons made a line a comment - bool comment = (tmp[first_non_white_char] == '#') || (tmp[first_non_white_char] == ';'); + bool comment = (tmp[first_non_white_char] == '#') or (tmp[first_non_white_char] == ';'); bool commented_rule = tmp.substr(0, 7) == "# alert"; if ( !commented_rule && ((first_non_white_char == std::string::npos) || comment) )