"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tools/snort2lua/helpers/s2l_util.cc" between
snort3-3.1.36.0.tar.gz and snort3-3.1.38.0.tar.gz

About: Snort 3 is a network intrusion prevention and detection system (IDS/IPS) combining the benefits of signature, protocol and anomaly-based inspection.

s2l_util.cc  (snort3-3.1.36.0):s2l_util.cc  (snort3-3.1.38.0)
skipping to change at line 127 skipping to change at line 127
return s; return s;
} }
std::string& trim(std::string& s) std::string& trim(std::string& s)
{ {
return ltrim(rtrim(s)); return ltrim(rtrim(s));
} }
std::string& trim_quotes(std::string& s) std::string& trim_quotes(std::string& s)
{ {
if(s.length() < 2) if (s.length() < 2)
return s; return s;
if((s.front() == '"' and s.back() == '"') or if ((s.front() == '"' and s.back() == '"') or
(s.front() == '\'' and s.back() == '\'')) (s.front() == '\'' and s.back() == '\''))
{ {
s.erase(0,1); s.erase(0,1);
s.pop_back(); s.pop_back();
} }
return s; return s;
} }
std::string& sanitize_lua_string(std::string& s) std::string& sanitize_lua_string(std::string& s)
skipping to change at line 227 skipping to change at line 227
first_delim = option.size(); // set value to take proper substr first_delim = option.size(); // set value to take proper substr
else else
stream.seekg((std::streamoff)(pos) + (std::streamoff)(first_delim) + 1); stream.seekg((std::streamoff)(pos) + (std::streamoff)(first_delim) + 1);
option = option.substr(first_char, first_delim - first_char); option = option.substr(first_char, first_delim - first_char);
trim(option); trim(option);
return true; return true;
} }
} }
std::string get_remain_data(std::istringstream& stream) std::string get_remain_data(std::istringstream& stream, bool trim)
{ {
// get string length // get string length
const std::streamoff pos = stream.tellg(); const std::streamoff pos = stream.tellg();
stream.seekg(0, stream.end); stream.seekg(0, stream.end);
const std::streamoff length = stream.tellg() - pos; const std::streamoff length = stream.tellg() - pos;
stream.seekg(pos); stream.seekg(pos);
// read argument // read argument
char* arg_c = new char[length + 1]; char* arg_c = new char[length + 1];
stream.read(arg_c, length); stream.read(arg_c, length);
arg_c[length] = '\0'; arg_c[length] = '\0';
std::string arg_s(arg_c); std::string arg_s(arg_c);
delete[] arg_c; delete[] arg_c;
util::trim(arg_s);
if (trim)
util::trim(arg_s);
return arg_s; return arg_s;
} }
static bool is_semicolon_escaped(const std::string& args)
{
unsigned bs_count = 0;
for (auto sym_it = args.rbegin();
sym_it != args.rend() and *sym_it == '\\';
++sym_it, ++bs_count);
return bs_count % 2;
}
std::string get_rule_option_args(std::istringstream& stream) std::string get_rule_option_args(std::istringstream& stream)
{ {
std::string args = std::string(); std::string args = std::string();
std::string tmp; std::string tmp;
do do
{ {
std::getline(stream, tmp, ';'); std::getline(stream, tmp, ';');
args += tmp + ";";
if (tmp.empty()) if (tmp.empty())
break; break;
args += tmp + ";";
} }
while (tmp.back() == '\\'); while (is_semicolon_escaped(tmp));
// semicolon will be added when printing // semicolon will be added when printing
if (!args.empty()) if (!args.empty())
args.pop_back(); args.pop_back();
trim(args); trim(args);
return args; return args;
} }
bool file_exists(const std::string& name) bool file_exists(const std::string& name)
 End of changes. 8 change blocks. 
7 lines changed or deleted 21 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)