"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/service_inspectors/wizard/spells.cc" between
snort3-3.1.29.0.tar.gz and snort3-3.1.30.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.29.0):spells.cc  (snort3-3.1.30.0)
skipping to change at line 70 skipping to change at line 70
} }
else else
{ {
if ( in[i] == '*' ) if ( in[i] == '*' )
wild = true; wild = true;
else else
out.emplace_back(in[i]); out.emplace_back(in[i]);
} }
++i; ++i;
} }
return true; return true;
} }
void SpellBook::add_spell( void SpellBook::add_spell(
const char* key, const char* val, HexVector& hv, unsigned i, MagicPage* p) const char* key, const char* val, HexVector& hv, unsigned i, MagicPage* p)
{ {
while ( i < hv.size() ) while ( i < hv.size() )
{ {
MagicPage* t = new MagicPage(*this); MagicPage* t = new MagicPage(*this);
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 = snort::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;
} }
unsigned i = 0; unsigned i = 0;
MagicPage* p = root; MagicPage* p = root;
// Perform a longest prefix match before inserting the pattern. // Perform a longest prefix match before inserting the pattern.
while ( i < hv.size() ) while ( i < hv.size() )
{ {
int c = toupper(hv[i]); int c = toupper(hv[i]);
if ( c == WILD && p->any ) if ( c == WILD and p->any )
p = p->any; p = p->any;
else if ( c != WILD && p->next[c] ) else if ( c != WILD and p->next[c] )
p = p->next[c]; p = p->next[c];
else else
break; break;
++i; ++i;
} }
if ( p->key == key ) if ( p->key == key )
{ {
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 MagicPag e*& bookmark) 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]);
skipping to change at line 159 skipping to change at line 164
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, bookmark) ) if ( const MagicPage* q = find_spell(s, n, p->any, i, bookmark) )
{ {
bookmark = q->any ? q : p; bookmark = q->any ? q : p;
return q; return q;
} }
++i; ++i;
} }
return p; return p;
} }
// If no match but has bookmark, continue lookup from bookmark // If no match but has bookmark, continue lookup from bookmark
if ( !p->value && bookmark ) if ( !p->value and bookmark )
{ {
p = bookmark; p = bookmark;
bookmark = nullptr; bookmark = nullptr;
return find_spell(s, n, p, i, bookmark); 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. 12 change blocks. 
3 lines changed or deleted 12 lines changed or added

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