"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/service_inspectors/wizard/spells.cc" between
snort3-3.1.28.0.tar.gz and snort3-3.1.29.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.

spells.cc  (snort3-3.1.28.0):spells.cc  (snort3-3.1.29.0)
skipping to change at line 30 skipping to change at line 30
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include "config.h" #include "config.h"
#endif #endif
#include <cassert> #include <cassert>
#include "main/snort_config.h" #include "main/snort_config.h"
#include "magic.h" #include "magic.h"
using namespace snort;
using namespace std; using namespace std;
#define WILD 0x100 #define WILD 0x100
SpellBook::SpellBook() : glob(nullptr) SpellBook::SpellBook()
{ {
// allows skipping leading whitespace only // allows skipping leading whitespace only
root->next[(int)' '] = root; root->next[(int)' '] = root;
root->next[(int)'\t'] = root; root->next[(int)'\t'] = root;
root->next[(int)'\r'] = root; root->next[(int)'\r'] = root;
root->next[(int)'\n'] = root; root->next[(int)'\n'] = root;
} }
bool SpellBook::translate(const char* in, HexVector& out) bool SpellBook::translate(const char* in, HexVector& out)
{ {
skipping to change at line 90 skipping to change at line 89
if ( hv[i] == WILD ) if ( hv[i] == WILD )
p->any = t; p->any = t;
else else
p->next[toupper(hv[i])] = t; p->next[toupper(hv[i])] = t;
p = t; p = t;
++i; ++i;
} }
p->key = key; p->key = key;
p->value = SnortConfig::get_static_name(val); p->value = snort::SnortConfig::get_static_name(val);
} }
bool SpellBook::add_spell(const char* key, const char*& val) bool SpellBook::add_spell(const char* key, const char*& val)
{ {
HexVector hv; HexVector hv;
if ( !translate(key, hv) ) if ( !translate(key, hv) )
{ {
val = nullptr; val = nullptr;
return false; return false;
skipping to change at line 133 skipping to change at line 132
{ {
val = p->value; val = p->value;
return false; return false;
} }
add_spell(key, val, hv, i, p); add_spell(key, val, hv, i, p);
return true; return true;
} }
const MagicPage* SpellBook::find_spell( const MagicPage* SpellBook::find_spell(
const uint8_t* s, unsigned n, const MagicPage* p, unsigned i) const const uint8_t* s, unsigned n, const MagicPage* p, unsigned i, const MagicPag e*& bookmark) const
{ {
while ( i < n ) while ( i < n )
{ {
int c = toupper(s[i]); int c = toupper(s[i]);
if ( p->next[c] ) if ( p->next[c] )
{ {
if ( p->any ) if ( p->any )
{ {
if ( const MagicPage* q = find_spell(s, n, p->next[c], i+1) ) if ( const MagicPage* q = find_spell(s, n, p->next[c], i+1, book mark) )
return q; return q;
} }
else else
{ {
p = p->next[c]; p = p->next[c];
++i; ++i;
continue; continue;
} }
} }
if ( p->any ) if ( p->any )
{ {
while ( i < n ) while ( i < n )
{ {
if ( const MagicPage* q = find_spell(s, n, p->any, i) ) if ( const MagicPage* q = find_spell(s, n, p->any, i, bookmark) )
{ {
glob = q->any ? q : p; bookmark = q->any ? q : p;
return q; return q;
} }
++i; ++i;
} }
return p; return p;
} }
// If no match but has glob, continue lookup from glob // If no match but has bookmark, continue lookup from bookmark
if ( !p->value && glob ) if ( !p->value && bookmark )
{ {
p = glob; p = bookmark;
glob = nullptr; bookmark = nullptr;
return find_spell(s, n, p, i); return find_spell(s, n, p, i, bookmark);
} }
return p->value ? p : nullptr; return p->value ? p : nullptr;
} }
return p; return p;
} }
 End of changes. 10 change blocks. 
12 lines changed or deleted 11 lines changed or added

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