mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Merge remote-tracking branch 'origin/topic/jsiwek/coverity'
* origin/topic/jsiwek/coverity: Fix uninitialized (or unused) fields. Remove logically dead code. Remove dead/unfinished code in unary not expr. Fix logic for failed DNS TXT lookups. A couple null ptr checks. Improve return value checking and error handling. Remove unused variable assignments, dead code. Prevent division/modulo by zero in scripts. Fix unintentional always-false condition. Fix invalidated iterator usage. Fix DNS_Mgr iterator mismatch. Set safe umask when creating script profiler tmp files. Fix nesting/indent level whitespace mismatch. Add checks to avoid improper negative values use. BIT-1085 #merged
This commit is contained in:
commit
d127d8d01d
86 changed files with 517 additions and 242 deletions
30
CHANGES
30
CHANGES
|
@ -1,4 +1,34 @@
|
||||||
|
|
||||||
|
2.2-beta-38 | 2013-10-02 11:03:29 -0700
|
||||||
|
|
||||||
|
* Fix uninitialized (or unused) fields. (Jon Siwek)
|
||||||
|
|
||||||
|
* Remove logically dead code. (Jon Siwek)
|
||||||
|
|
||||||
|
* Remove dead/unfinished code in unary not expression. (Jon Siwek)
|
||||||
|
|
||||||
|
* Fix logic for failed DNS TXT lookups. (Jon Siwek)
|
||||||
|
|
||||||
|
* A couple null ptr checks. (Jon Siwek)
|
||||||
|
|
||||||
|
* Improve return value checking and error handling. (Jon Siwek)
|
||||||
|
|
||||||
|
* Remove unused variable assignments. (Jon Siwek)
|
||||||
|
|
||||||
|
* Prevent division/modulo by zero in scripts. (Jon Siwek)
|
||||||
|
|
||||||
|
* Fix unintentional always-false condition. (Jon Siwek)
|
||||||
|
|
||||||
|
* Fix invalidated iterator usage. (Jon Siwek)
|
||||||
|
|
||||||
|
* Fix DNS_Mgr iterator mismatch. (Jon Siwek)
|
||||||
|
|
||||||
|
* Set safe umask when creating script profiler tmp files. (Jon Siwek)
|
||||||
|
|
||||||
|
* Fix nesting/indent level whitespace mismatch. (Jon Siwek)
|
||||||
|
|
||||||
|
* Add checks to avoid improper negative values use. (Jon Siwek)
|
||||||
|
|
||||||
2.2-beta-18 | 2013-10-02 10:28:17 -0700
|
2.2-beta-18 | 2013-10-02 10:28:17 -0700
|
||||||
|
|
||||||
* Add support for further TLS cipher suites. (Bernhard Amann)
|
* Add support for further TLS cipher suites. (Bernhard Amann)
|
||||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
2.2-beta-18
|
2.2-beta-38
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit d4331881f91068da9a7a7d6639559ce752e178ad
|
Subproject commit a5700df61aa195a67dc529553a6bee81740c88b5
|
|
@ -1 +1 @@
|
||||||
Subproject commit 1aef055802f842502d701ad152305bcd74bba632
|
Subproject commit 5f5f25570c65dbb14c01dd998656abbab7f55850
|
|
@ -147,7 +147,9 @@ void AnonymizeIPAddr_A50::init()
|
||||||
special_nodes[0].input = special_nodes[0].output = 0;
|
special_nodes[0].input = special_nodes[0].output = 0;
|
||||||
special_nodes[1].input = special_nodes[1].output = 0xFFFFFFFF;
|
special_nodes[1].input = special_nodes[1].output = 0xFFFFFFFF;
|
||||||
|
|
||||||
|
method = 0;
|
||||||
before_anonymization = 1;
|
before_anonymization = 1;
|
||||||
|
new_mapping = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int AnonymizeIPAddr_A50::PreservePrefix(ipaddr32_t input, int num_bits)
|
int AnonymizeIPAddr_A50::PreservePrefix(ipaddr32_t input, int num_bits)
|
||||||
|
|
|
@ -96,7 +96,7 @@ public:
|
||||||
bool operator==(const Attributes& other) const;
|
bool operator==(const Attributes& other) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Attributes() { type = 0; attrs = 0; }
|
Attributes() : type(), attrs(), in_record() { }
|
||||||
void CheckAttr(Attr* attr);
|
void CheckAttr(Attr* attr);
|
||||||
|
|
||||||
DECLARE_SERIAL(Attributes);
|
DECLARE_SERIAL(Attributes);
|
||||||
|
|
|
@ -58,9 +58,8 @@ int pcap_compile_nopcap(int snaplen_arg, int linktype_arg,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
BPF_Program::BPF_Program()
|
BPF_Program::BPF_Program() : m_compiled(), m_program()
|
||||||
{
|
{
|
||||||
m_compiled = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BPF_Program::~BPF_Program()
|
BPF_Program::~BPF_Program()
|
||||||
|
|
|
@ -504,17 +504,35 @@ static void WritePluginComponents(FILE* f, const plugin::Plugin* p)
|
||||||
{
|
{
|
||||||
switch ( (*it)->Type() ) {
|
switch ( (*it)->Type() ) {
|
||||||
case plugin::component::ANALYZER:
|
case plugin::component::ANALYZER:
|
||||||
WriteAnalyzerComponent(f,
|
{
|
||||||
dynamic_cast<const analyzer::Component*>(*it));
|
const analyzer::Component* c =
|
||||||
|
dynamic_cast<const analyzer::Component*>(*it);
|
||||||
|
|
||||||
|
if ( c )
|
||||||
|
WriteAnalyzerComponent(f, c);
|
||||||
|
else
|
||||||
|
reporter->InternalError("component type mismatch");
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case plugin::component::FILE_ANALYZER:
|
case plugin::component::FILE_ANALYZER:
|
||||||
WriteAnalyzerComponent(f,
|
{
|
||||||
dynamic_cast<const file_analysis::Component*>(*it));
|
const file_analysis::Component* c =
|
||||||
|
dynamic_cast<const file_analysis::Component*>(*it);
|
||||||
|
|
||||||
|
if ( c )
|
||||||
|
WriteAnalyzerComponent(f, c);
|
||||||
|
else
|
||||||
|
reporter->InternalError("component type mismatch");
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case plugin::component::READER:
|
case plugin::component::READER:
|
||||||
reporter->InternalError("docs for READER component unimplemented");
|
reporter->InternalError("docs for READER component unimplemented");
|
||||||
|
|
||||||
case plugin::component::WRITER:
|
case plugin::component::WRITER:
|
||||||
reporter->InternalError("docs for WRITER component unimplemented");
|
reporter->InternalError("docs for WRITER component unimplemented");
|
||||||
|
|
||||||
default:
|
default:
|
||||||
reporter->InternalError("docs for unknown component unimplemented");
|
reporter->InternalError("docs for unknown component unimplemented");
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <sys/stat.h>
|
||||||
#include "Brofiler.h"
|
#include "Brofiler.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
|
@ -54,7 +55,10 @@ bool Brofiler::WriteStats()
|
||||||
|
|
||||||
if ( p && ! p[7] )
|
if ( p && ! p[7] )
|
||||||
{
|
{
|
||||||
|
mode_t old_umask = umask(S_IXUSR | S_IRWXO | S_IRWXG);
|
||||||
int fd = mkstemp(bf);
|
int fd = mkstemp(bf);
|
||||||
|
umask(old_umask);
|
||||||
|
|
||||||
if ( fd == -1 )
|
if ( fd == -1 )
|
||||||
{
|
{
|
||||||
reporter->Error("Failed to generate unique file name from BRO_PROFILER_FILE: %s", bf);
|
reporter->Error("Failed to generate unique file name from BRO_PROFILER_FILE: %s", bf);
|
||||||
|
|
|
@ -14,9 +14,8 @@
|
||||||
#include "NetVar.h"
|
#include "NetVar.h"
|
||||||
#include "RemoteSerializer.h"
|
#include "RemoteSerializer.h"
|
||||||
|
|
||||||
ChunkedIO::ChunkedIO()
|
ChunkedIO::ChunkedIO() : stats(), tag(), pure()
|
||||||
{
|
{
|
||||||
pure = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChunkedIO::Stats(char* buffer, int length)
|
void ChunkedIO::Stats(char* buffer, int length)
|
||||||
|
@ -656,6 +655,7 @@ SSL_CTX* ChunkedIOSSL::ctx;
|
||||||
ChunkedIOSSL::ChunkedIOSSL(int arg_socket, bool arg_server)
|
ChunkedIOSSL::ChunkedIOSSL(int arg_socket, bool arg_server)
|
||||||
{
|
{
|
||||||
socket = arg_socket;
|
socket = arg_socket;
|
||||||
|
last_ret = 0;
|
||||||
eof = false;
|
eof = false;
|
||||||
setup = false;
|
setup = false;
|
||||||
server = arg_server;
|
server = arg_server;
|
||||||
|
|
|
@ -292,8 +292,9 @@ private:
|
||||||
// Wrapper class around a another ChunkedIO which the (un-)compresses data.
|
// Wrapper class around a another ChunkedIO which the (un-)compresses data.
|
||||||
class CompressedChunkedIO : public ChunkedIO {
|
class CompressedChunkedIO : public ChunkedIO {
|
||||||
public:
|
public:
|
||||||
CompressedChunkedIO(ChunkedIO* arg_io)
|
CompressedChunkedIO(ChunkedIO* arg_io) // takes ownership
|
||||||
: io(arg_io) {} // takes ownership
|
: io(arg_io), zin(), zout(), error(), compress(), uncompress(),
|
||||||
|
uncompressed_bytes_read(), uncompressed_bytes_written() {}
|
||||||
virtual ~CompressedChunkedIO() { delete io; }
|
virtual ~CompressedChunkedIO() { delete io; }
|
||||||
|
|
||||||
virtual bool Init(); // does *not* call arg_io->Init()
|
virtual bool Init(); // does *not* call arg_io->Init()
|
||||||
|
|
|
@ -11,6 +11,7 @@ CompositeHash::CompositeHash(TypeList* composite_type)
|
||||||
{
|
{
|
||||||
type = composite_type;
|
type = composite_type;
|
||||||
Ref(type);
|
Ref(type);
|
||||||
|
singleton_tag = TYPE_INTERNAL_ERROR;
|
||||||
|
|
||||||
// If the only element is a record, don't treat it as a
|
// If the only element is a record, don't treat it as a
|
||||||
// singleton, since it needs to be evaluated specially.
|
// singleton, since it needs to be evaluated specially.
|
||||||
|
@ -207,7 +208,6 @@ char* CompositeHash::SingleValHash(int type_check, char* kp0,
|
||||||
unsigned int* kp = AlignAndPadType<unsigned int>(kp0);
|
unsigned int* kp = AlignAndPadType<unsigned int>(kp0);
|
||||||
VectorVal* vv = v->AsVectorVal();
|
VectorVal* vv = v->AsVectorVal();
|
||||||
VectorType* vt = v->Type()->AsVectorType();
|
VectorType* vt = v->Type()->AsVectorType();
|
||||||
vector<Val*>* indices = v->AsVector();
|
|
||||||
*kp = vv->Size();
|
*kp = vv->Size();
|
||||||
kp1 = reinterpret_cast<char*>(kp+1);
|
kp1 = reinterpret_cast<char*>(kp+1);
|
||||||
for ( unsigned int i = 0; i < vv->Size(); ++i )
|
for ( unsigned int i = 0; i < vv->Size(); ++i )
|
||||||
|
|
|
@ -141,6 +141,7 @@ Connection::Connection(NetSessions* s, HashKey* k, double t, const ConnID* id,
|
||||||
suppress_event = 0;
|
suppress_event = 0;
|
||||||
|
|
||||||
record_contents = record_packets = 1;
|
record_contents = record_packets = 1;
|
||||||
|
record_current_packet = record_current_content = 0;
|
||||||
|
|
||||||
timers_canceled = 0;
|
timers_canceled = 0;
|
||||||
inactivity_timeout = 0;
|
inactivity_timeout = 0;
|
||||||
|
|
|
@ -20,6 +20,7 @@ DFA_State::DFA_State(int arg_state_num, const EquivClass* ec,
|
||||||
nfa_states = arg_nfa_states;
|
nfa_states = arg_nfa_states;
|
||||||
accept = arg_accept;
|
accept = arg_accept;
|
||||||
mark = 0;
|
mark = 0;
|
||||||
|
centry = 0;
|
||||||
|
|
||||||
SymPartition(ec);
|
SymPartition(ec);
|
||||||
|
|
||||||
|
|
|
@ -47,8 +47,14 @@ extern int select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
|
||||||
class DNS_Mgr_Request {
|
class DNS_Mgr_Request {
|
||||||
public:
|
public:
|
||||||
DNS_Mgr_Request(const char* h, int af, bool is_txt)
|
DNS_Mgr_Request(const char* h, int af, bool is_txt)
|
||||||
{ host = copy_string(h); fam = af; qtype = is_txt ? 16 : 0; }
|
: host(copy_string(h)), fam(af), qtype(is_txt ? 16 : 0), addr(),
|
||||||
DNS_Mgr_Request(const IPAddr& a) { addr = a; host = 0; fam = 0; }
|
request_pending()
|
||||||
|
{ }
|
||||||
|
|
||||||
|
DNS_Mgr_Request(const IPAddr& a)
|
||||||
|
: host(), fam(), qtype(), addr(a), request_pending()
|
||||||
|
{ }
|
||||||
|
|
||||||
~DNS_Mgr_Request() { delete [] host; }
|
~DNS_Mgr_Request() { delete [] host; }
|
||||||
|
|
||||||
// Returns nil if this was an address request.
|
// Returns nil if this was an address request.
|
||||||
|
@ -192,6 +198,8 @@ DNS_Mapping::DNS_Mapping(FILE* f)
|
||||||
init_failed = 1;
|
init_failed = 1;
|
||||||
|
|
||||||
req_host = 0;
|
req_host = 0;
|
||||||
|
req_ttl = 0;
|
||||||
|
creation_time = 0;
|
||||||
|
|
||||||
char buf[512];
|
char buf[512];
|
||||||
|
|
||||||
|
@ -711,17 +719,19 @@ void DNS_Mgr::AddResult(DNS_Mgr_Request* dr, struct nb_dns_result* r)
|
||||||
if ( dr->ReqIsTxt() )
|
if ( dr->ReqIsTxt() )
|
||||||
{
|
{
|
||||||
TextMap::iterator it = text_mappings.find(dr->ReqHost());
|
TextMap::iterator it = text_mappings.find(dr->ReqHost());
|
||||||
|
|
||||||
if ( it == text_mappings.end() )
|
if ( it == text_mappings.end() )
|
||||||
text_mappings[dr->ReqHost()] = new_dm;
|
text_mappings[dr->ReqHost()] = new_dm;
|
||||||
else
|
|
||||||
{
|
|
||||||
if ( new_dm->Failed() && prev_dm && prev_dm->Valid() )
|
|
||||||
++keep_prev;
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
prev_dm = it->second;
|
prev_dm = it->second;
|
||||||
it->second = new_dm;
|
it->second = new_dm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( new_dm->Failed() && prev_dm && prev_dm->Valid() )
|
||||||
|
{
|
||||||
|
text_mappings[dr->ReqHost()] = prev_dm;
|
||||||
|
++keep_prev;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -928,7 +938,7 @@ void DNS_Mgr::Save(FILE* f, const HostMap& m)
|
||||||
|
|
||||||
const char* DNS_Mgr::LookupAddrInCache(const IPAddr& addr)
|
const char* DNS_Mgr::LookupAddrInCache(const IPAddr& addr)
|
||||||
{
|
{
|
||||||
AddrMap::iterator it = dns_mgr->addr_mappings.find(addr);
|
AddrMap::iterator it = addr_mappings.find(addr);
|
||||||
|
|
||||||
if ( it == addr_mappings.end() )
|
if ( it == addr_mappings.end() )
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -937,7 +947,7 @@ const char* DNS_Mgr::LookupAddrInCache(const IPAddr& addr)
|
||||||
|
|
||||||
if ( d->Expired() )
|
if ( d->Expired() )
|
||||||
{
|
{
|
||||||
dns_mgr->addr_mappings.erase(it);
|
addr_mappings.erase(it);
|
||||||
delete d;
|
delete d;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -949,10 +959,10 @@ const char* DNS_Mgr::LookupAddrInCache(const IPAddr& addr)
|
||||||
|
|
||||||
TableVal* DNS_Mgr::LookupNameInCache(string name)
|
TableVal* DNS_Mgr::LookupNameInCache(string name)
|
||||||
{
|
{
|
||||||
HostMap::iterator it = dns_mgr->host_mappings.find(name);
|
HostMap::iterator it = host_mappings.find(name);
|
||||||
if ( it == dns_mgr->host_mappings.end() )
|
if ( it == host_mappings.end() )
|
||||||
{
|
{
|
||||||
it = dns_mgr->host_mappings.begin();
|
it = host_mappings.begin();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -964,7 +974,7 @@ TableVal* DNS_Mgr::LookupNameInCache(string name)
|
||||||
|
|
||||||
if ( d4->Expired() || d6->Expired() )
|
if ( d4->Expired() || d6->Expired() )
|
||||||
{
|
{
|
||||||
dns_mgr->host_mappings.erase(it);
|
host_mappings.erase(it);
|
||||||
delete d4;
|
delete d4;
|
||||||
delete d6;
|
delete d6;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -979,15 +989,15 @@ TableVal* DNS_Mgr::LookupNameInCache(string name)
|
||||||
|
|
||||||
const char* DNS_Mgr::LookupTextInCache(string name)
|
const char* DNS_Mgr::LookupTextInCache(string name)
|
||||||
{
|
{
|
||||||
TextMap::iterator it = dns_mgr->text_mappings.find(name);
|
TextMap::iterator it = text_mappings.find(name);
|
||||||
if ( it == dns_mgr->text_mappings.end() )
|
if ( it == text_mappings.end() )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
DNS_Mapping* d = it->second;
|
DNS_Mapping* d = it->second;
|
||||||
|
|
||||||
if ( d->Expired() )
|
if ( d->Expired() )
|
||||||
{
|
{
|
||||||
dns_mgr->text_mappings.erase(it);
|
text_mappings.erase(it);
|
||||||
delete d;
|
delete d;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,6 +49,8 @@ DbgBreakpoint::DbgBreakpoint()
|
||||||
repeat_count = hit_count = 0;
|
repeat_count = hit_count = 0;
|
||||||
|
|
||||||
description[0] = 0;
|
description[0] = 0;
|
||||||
|
source_filename = 0;
|
||||||
|
source_line = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DbgBreakpoint::~DbgBreakpoint()
|
DbgBreakpoint::~DbgBreakpoint()
|
||||||
|
@ -85,10 +87,17 @@ void DbgBreakpoint::RemoveFromGlobalMap()
|
||||||
pair<BPMapType::iterator, BPMapType::iterator> p;
|
pair<BPMapType::iterator, BPMapType::iterator> p;
|
||||||
p = g_debugger_state.breakpoint_map.equal_range(at_stmt);
|
p = g_debugger_state.breakpoint_map.equal_range(at_stmt);
|
||||||
|
|
||||||
for ( BPMapType::iterator i = p.first; i != p.second; ++i )
|
for ( BPMapType::iterator i = p.first; i != p.second; )
|
||||||
{
|
{
|
||||||
if ( i->second == this )
|
if ( i->second == this )
|
||||||
|
{
|
||||||
|
BPMapType::iterator next = i;
|
||||||
|
++next;
|
||||||
g_debugger_state.breakpoint_map.erase(i);
|
g_debugger_state.breakpoint_map.erase(i);
|
||||||
|
i = next;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
++i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,7 @@ DebuggerState::DebuggerState()
|
||||||
next_bp_id = next_watch_id = next_display_id = 1;
|
next_bp_id = next_watch_id = next_display_id = 1;
|
||||||
BreakBeforeNextStmt(false);
|
BreakBeforeNextStmt(false);
|
||||||
curr_frame_idx = 0;
|
curr_frame_idx = 0;
|
||||||
|
already_did_list = false;
|
||||||
BreakFromSignal(false);
|
BreakFromSignal(false);
|
||||||
|
|
||||||
// ### Don't choose this arbitrary size! Extend Frame.
|
// ### Don't choose this arbitrary size! Extend Frame.
|
||||||
|
@ -194,8 +195,7 @@ static void parse_function_name(vector<ParseLocationRec>& result,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
FuncType* ftype;
|
if ( ! id->Type()->AsFuncType() )
|
||||||
if ( ! (ftype = id->Type()->AsFuncType()) )
|
|
||||||
{
|
{
|
||||||
debug_msg("Function %s not declared.\n", id->Name());
|
debug_msg("Function %s not declared.\n", id->Name());
|
||||||
plr.type = plrUnknown;
|
plr.type = plrUnknown;
|
||||||
|
@ -722,7 +722,7 @@ static char* get_prompt(bool reset_counter = false)
|
||||||
string get_context_description(const Stmt* stmt, const Frame* frame)
|
string get_context_description(const Stmt* stmt, const Frame* frame)
|
||||||
{
|
{
|
||||||
ODesc d;
|
ODesc d;
|
||||||
const BroFunc* func = frame->GetFunction();
|
const BroFunc* func = frame ? frame->GetFunction() : 0;
|
||||||
|
|
||||||
if ( func )
|
if ( func )
|
||||||
func->DescribeDebug(&d, frame->GetFuncArgs());
|
func->DescribeDebug(&d, frame->GetFuncArgs());
|
||||||
|
|
|
@ -64,6 +64,10 @@ Dictionary::Dictionary(dict_order ordering, int initial_size)
|
||||||
SetDensityThresh(DEFAULT_DENSITY_THRESH);
|
SetDensityThresh(DEFAULT_DENSITY_THRESH);
|
||||||
|
|
||||||
delete_func = 0;
|
delete_func = 0;
|
||||||
|
tbl_next_ind = 0;
|
||||||
|
|
||||||
|
num_buckets2 = num_entries2 = max_num_entries2 = thresh_entries2 = 0;
|
||||||
|
den_thresh2 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Dictionary::~Dictionary()
|
Dictionary::~Dictionary()
|
||||||
|
|
87
src/Expr.cc
87
src/Expr.cc
|
@ -779,9 +779,58 @@ Val* BinaryExpr::Fold(Val* v1, Val* v2) const
|
||||||
case EXPR_SUB: DO_FOLD(-); break;
|
case EXPR_SUB: DO_FOLD(-); break;
|
||||||
case EXPR_REMOVE_FROM: DO_FOLD(-); break;
|
case EXPR_REMOVE_FROM: DO_FOLD(-); break;
|
||||||
case EXPR_TIMES: DO_FOLD(*); break;
|
case EXPR_TIMES: DO_FOLD(*); break;
|
||||||
case EXPR_DIVIDE: DO_FOLD(/); break;
|
case EXPR_DIVIDE:
|
||||||
|
{
|
||||||
|
if ( is_integral )
|
||||||
|
{
|
||||||
|
if ( i2 == 0 )
|
||||||
|
reporter->ExprRuntimeError(this, "division by zero");
|
||||||
|
|
||||||
|
i3 = i1 / i2;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if ( is_unsigned )
|
||||||
|
{
|
||||||
|
if ( u2 == 0 )
|
||||||
|
reporter->ExprRuntimeError(this, "division by zero");
|
||||||
|
|
||||||
|
u3 = u1 / u2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( d2 == 0 )
|
||||||
|
reporter->ExprRuntimeError(this, "division by zero");
|
||||||
|
|
||||||
|
d3 = d1 / d2;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EXPR_MOD:
|
||||||
|
{
|
||||||
|
if ( is_integral )
|
||||||
|
{
|
||||||
|
if ( i2 == 0 )
|
||||||
|
reporter->ExprRuntimeError(this, "modulo by zero");
|
||||||
|
|
||||||
|
i3 = i1 % i2;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if ( is_unsigned )
|
||||||
|
{
|
||||||
|
if ( u2 == 0 )
|
||||||
|
reporter->ExprRuntimeError(this, "modulo by zero");
|
||||||
|
|
||||||
|
u3 = u1 % u2;
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
Internal("bad type in BinaryExpr::Fold");
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
case EXPR_MOD: DO_INT_FOLD(%); break;
|
|
||||||
case EXPR_AND: DO_INT_FOLD(&&); break;
|
case EXPR_AND: DO_INT_FOLD(&&); break;
|
||||||
case EXPR_OR: DO_INT_FOLD(||); break;
|
case EXPR_OR: DO_INT_FOLD(||); break;
|
||||||
|
|
||||||
|
@ -1090,15 +1139,10 @@ NotExpr::NotExpr(Expr* arg_op) : UnaryExpr(EXPR_NOT, arg_op)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BroType* t = op->Type();
|
BroType* t = op->Type();
|
||||||
if ( IsVector(t->Tag()) )
|
|
||||||
t = t->AsVectorType()->YieldType();
|
|
||||||
|
|
||||||
TypeTag bt = t->Tag();
|
TypeTag bt = t->Tag();
|
||||||
|
|
||||||
if ( ! IsIntegral(bt) && bt != TYPE_BOOL )
|
if ( ! IsIntegral(bt) && bt != TYPE_BOOL )
|
||||||
ExprError("requires an integral or boolean operand");
|
ExprError("requires an integral or boolean operand");
|
||||||
else if ( IsVector(bt) )
|
|
||||||
SetType(new VectorType(base_type(TYPE_BOOL)));
|
|
||||||
else
|
else
|
||||||
SetType(base_type(TYPE_BOOL));
|
SetType(base_type(TYPE_BOOL));
|
||||||
}
|
}
|
||||||
|
@ -1112,7 +1156,7 @@ Expr* NotExpr::DoSimplify()
|
||||||
// !!x == x
|
// !!x == x
|
||||||
return ((NotExpr*) op)->Op()->Ref();
|
return ((NotExpr*) op)->Op()->Ref();
|
||||||
|
|
||||||
if ( op->IsConst() && ! is_vector(op->ExprVal()) )
|
if ( op->IsConst() )
|
||||||
return new ConstExpr(Fold(op->ExprVal()));
|
return new ConstExpr(Fold(op->ExprVal()));
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
|
@ -2438,6 +2482,7 @@ AssignExpr::AssignExpr(Expr* arg_op1, Expr* arg_op2, int arg_is_init,
|
||||||
: BinaryExpr(EXPR_ASSIGN,
|
: BinaryExpr(EXPR_ASSIGN,
|
||||||
arg_is_init ? arg_op1 : arg_op1->MakeLvalue(), arg_op2)
|
arg_is_init ? arg_op1 : arg_op1->MakeLvalue(), arg_op2)
|
||||||
{
|
{
|
||||||
|
val = 0;
|
||||||
is_init = arg_is_init;
|
is_init = arg_is_init;
|
||||||
|
|
||||||
if ( IsError() )
|
if ( IsError() )
|
||||||
|
@ -3137,12 +3182,14 @@ FieldExpr::FieldExpr(Expr* arg_op, const char* arg_field_name)
|
||||||
{
|
{
|
||||||
RecordType* rt = op->Type()->AsRecordType();
|
RecordType* rt = op->Type()->AsRecordType();
|
||||||
field = rt->FieldOffset(field_name);
|
field = rt->FieldOffset(field_name);
|
||||||
td = rt->FieldDecl(field);
|
|
||||||
|
|
||||||
if ( field < 0 )
|
if ( field < 0 )
|
||||||
ExprError("no such field in record");
|
ExprError("no such field in record");
|
||||||
else
|
else
|
||||||
|
{
|
||||||
SetType(rt->FieldType(field)->Ref());
|
SetType(rt->FieldType(field)->Ref());
|
||||||
|
td = rt->FieldDecl(field);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3309,14 +3356,14 @@ bool HasFieldExpr::DoSerialize(SerialInfo* info) const
|
||||||
{
|
{
|
||||||
DO_SERIALIZE(SER_HAS_FIELD_EXPR, UnaryExpr);
|
DO_SERIALIZE(SER_HAS_FIELD_EXPR, UnaryExpr);
|
||||||
|
|
||||||
// Serialize the former "bool is_attr" first for backwards compatibility.
|
// Serialize former "bool is_attr" member first for backwards compatibility.
|
||||||
return SERIALIZE(false) && SERIALIZE(field_name) && SERIALIZE(field);
|
return SERIALIZE(false) && SERIALIZE(field_name) && SERIALIZE(field);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HasFieldExpr::DoUnserialize(UnserialInfo* info)
|
bool HasFieldExpr::DoUnserialize(UnserialInfo* info)
|
||||||
{
|
{
|
||||||
DO_UNSERIALIZE(UnaryExpr);
|
DO_UNSERIALIZE(UnaryExpr);
|
||||||
// Unserialize the former "bool is_attr" first for backwards compatibility.
|
// Unserialize former "bool is_attr" member for backwards compatibility.
|
||||||
bool not_used;
|
bool not_used;
|
||||||
return UNSERIALIZE(¬_used) && UNSERIALIZE_STR(&field_name, 0) && UNSERIALIZE(&field);
|
return UNSERIALIZE(¬_used) && UNSERIALIZE_STR(&field_name, 0) && UNSERIALIZE(&field);
|
||||||
}
|
}
|
||||||
|
@ -3325,6 +3372,8 @@ RecordConstructorExpr::RecordConstructorExpr(ListExpr* constructor_list,
|
||||||
BroType* arg_type)
|
BroType* arg_type)
|
||||||
: UnaryExpr(EXPR_RECORD_CONSTRUCTOR, constructor_list)
|
: UnaryExpr(EXPR_RECORD_CONSTRUCTOR, constructor_list)
|
||||||
{
|
{
|
||||||
|
ctor_type = 0;
|
||||||
|
|
||||||
if ( IsError() )
|
if ( IsError() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -3465,6 +3514,8 @@ TableConstructorExpr::TableConstructorExpr(ListExpr* constructor_list,
|
||||||
attr_list* arg_attrs, BroType* arg_type)
|
attr_list* arg_attrs, BroType* arg_type)
|
||||||
: UnaryExpr(EXPR_TABLE_CONSTRUCTOR, constructor_list)
|
: UnaryExpr(EXPR_TABLE_CONSTRUCTOR, constructor_list)
|
||||||
{
|
{
|
||||||
|
attrs = 0;
|
||||||
|
|
||||||
if ( IsError() )
|
if ( IsError() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -3589,6 +3640,8 @@ SetConstructorExpr::SetConstructorExpr(ListExpr* constructor_list,
|
||||||
attr_list* arg_attrs, BroType* arg_type)
|
attr_list* arg_attrs, BroType* arg_type)
|
||||||
: UnaryExpr(EXPR_SET_CONSTRUCTOR, constructor_list)
|
: UnaryExpr(EXPR_SET_CONSTRUCTOR, constructor_list)
|
||||||
{
|
{
|
||||||
|
attrs = 0;
|
||||||
|
|
||||||
if ( IsError() )
|
if ( IsError() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -3852,7 +3905,15 @@ void FieldAssignExpr::EvalIntoAggregate(const BroType* t, Val* aggr, Frame* f)
|
||||||
Val* v = op->Eval(f);
|
Val* v = op->Eval(f);
|
||||||
|
|
||||||
if ( v )
|
if ( v )
|
||||||
rec->Assign(rt->FieldOffset(field_name.c_str()), v);
|
{
|
||||||
|
int idx = rt->FieldOffset(field_name.c_str());
|
||||||
|
|
||||||
|
if ( idx < 0 )
|
||||||
|
reporter->InternalError("Missing record field: %s",
|
||||||
|
field_name.c_str());
|
||||||
|
|
||||||
|
rec->Assign(idx, v);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int FieldAssignExpr::IsRecordElement(TypeDecl* td) const
|
int FieldAssignExpr::IsRecordElement(TypeDecl* td) const
|
||||||
|
@ -5386,7 +5447,7 @@ TraversalCode ListExpr::Traverse(TraversalCallback* cb) const
|
||||||
|
|
||||||
loop_over_list(exprs, i)
|
loop_over_list(exprs, i)
|
||||||
{
|
{
|
||||||
exprs[i]->Traverse(cb);
|
tc = exprs[i]->Traverse(cb);
|
||||||
HANDLE_TC_EXPR_PRE(tc);
|
HANDLE_TC_EXPR_PRE(tc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -331,12 +331,10 @@ protected:
|
||||||
BinaryExpr() { op1 = op2 = 0; }
|
BinaryExpr() { op1 = op2 = 0; }
|
||||||
|
|
||||||
BinaryExpr(BroExprTag arg_tag, Expr* arg_op1, Expr* arg_op2)
|
BinaryExpr(BroExprTag arg_tag, Expr* arg_op1, Expr* arg_op2)
|
||||||
: Expr(arg_tag)
|
: Expr(arg_tag), op1(arg_op1), op2(arg_op2)
|
||||||
{
|
{
|
||||||
if ( ! (arg_op1 && arg_op2) )
|
if ( ! (arg_op1 && arg_op2) )
|
||||||
return;
|
return;
|
||||||
op1 = arg_op1;
|
|
||||||
op2 = arg_op2;
|
|
||||||
if ( op1->IsError() || op2->IsError() )
|
if ( op1->IsError() || op2->IsError() )
|
||||||
SetError();
|
SetError();
|
||||||
}
|
}
|
||||||
|
@ -749,7 +747,6 @@ protected:
|
||||||
|
|
||||||
DECLARE_SERIAL(HasFieldExpr);
|
DECLARE_SERIAL(HasFieldExpr);
|
||||||
|
|
||||||
bool is_attr;
|
|
||||||
const char* field_name;
|
const char* field_name;
|
||||||
int field;
|
int field;
|
||||||
};
|
};
|
||||||
|
|
|
@ -147,7 +147,6 @@ protected:
|
||||||
|
|
||||||
Timer* rotate_timer;
|
Timer* rotate_timer;
|
||||||
double open_time;
|
double open_time;
|
||||||
bool dont_rotate; // See InstallRotateTimer()
|
|
||||||
bool print_hook;
|
bool print_hook;
|
||||||
bool raw_output;
|
bool raw_output;
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,6 @@ void FlowSrc::Close()
|
||||||
|
|
||||||
FlowSocketSrc::~FlowSocketSrc()
|
FlowSocketSrc::~FlowSocketSrc()
|
||||||
{
|
{
|
||||||
delete [] listenparms;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int FlowSocketSrc::ExtractNextPDU()
|
int FlowSocketSrc::ExtractNextPDU()
|
||||||
|
|
|
@ -67,9 +67,6 @@ public:
|
||||||
virtual ~FlowSocketSrc();
|
virtual ~FlowSocketSrc();
|
||||||
|
|
||||||
int ExtractNextPDU();
|
int ExtractNextPDU();
|
||||||
|
|
||||||
protected:
|
|
||||||
char* listenparms;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class FlowFileSrc : public FlowSrc {
|
class FlowFileSrc : public FlowSrc {
|
||||||
|
|
13
src/Obj.cc
13
src/Obj.cc
|
@ -28,11 +28,14 @@ bool Location::DoSerialize(SerialInfo* info) const
|
||||||
{
|
{
|
||||||
DO_SERIALIZE(SER_LOCATION, SerialObj);
|
DO_SERIALIZE(SER_LOCATION, SerialObj);
|
||||||
info->s->WriteOpenTag("Location");
|
info->s->WriteOpenTag("Location");
|
||||||
SERIALIZE(filename);
|
|
||||||
SERIALIZE(first_line);
|
if ( ! (SERIALIZE(filename) &&
|
||||||
SERIALIZE(last_line);
|
SERIALIZE(first_line) &&
|
||||||
SERIALIZE(first_column);
|
SERIALIZE(last_line) &&
|
||||||
SERIALIZE(last_column);
|
SERIALIZE(first_column) &&
|
||||||
|
SERIALIZE(last_column)) )
|
||||||
|
return false;
|
||||||
|
|
||||||
info->s->WriteCloseTag("Location");
|
info->s->WriteCloseTag("Location");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -400,8 +400,6 @@ bool PersistenceSerializer::RunSerialization(SerialStatus* status)
|
||||||
|
|
||||||
while ( (id = status->ids->NextEntry(status->id_cookie)) )
|
while ( (id = status->ids->NextEntry(status->id_cookie)) )
|
||||||
{
|
{
|
||||||
ID* g = global_scope()->Lookup(id->Name());
|
|
||||||
|
|
||||||
if ( ! DoIDSerialization(status, id) )
|
if ( ! DoIDSerialization(status, id) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <errno.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
@ -80,7 +81,13 @@ bool LoadPolicyFileText(const char* policy_filename)
|
||||||
policy_files.insert(PolicyFileMap::value_type(policy_filename, pf));
|
policy_files.insert(PolicyFileMap::value_type(policy_filename, pf));
|
||||||
|
|
||||||
struct stat st;
|
struct stat st;
|
||||||
fstat(fileno(f), &st);
|
if ( fstat(fileno(f), &st) != 0 )
|
||||||
|
{
|
||||||
|
char buf[256];
|
||||||
|
strerror_r(errno, buf, sizeof(buf));
|
||||||
|
reporter->Error("fstat failed on %s: %s", policy_filename, buf);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
pf->lmtime = st.st_mtime;
|
pf->lmtime = st.st_mtime;
|
||||||
off_t size = st.st_size;
|
off_t size = st.st_size;
|
||||||
|
|
|
@ -541,6 +541,10 @@ RemoteSerializer::RemoteSerializer()
|
||||||
in_sync = 0;
|
in_sync = 0;
|
||||||
last_flush = 0;
|
last_flush = 0;
|
||||||
received_logs = 0;
|
received_logs = 0;
|
||||||
|
current_id = 0;
|
||||||
|
current_msgtype = 0;
|
||||||
|
current_args = 0;
|
||||||
|
source_peer = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
RemoteSerializer::~RemoteSerializer()
|
RemoteSerializer::~RemoteSerializer()
|
||||||
|
@ -1247,7 +1251,7 @@ bool RemoteSerializer::SendCapabilities(Peer* peer)
|
||||||
caps |= Peer::PID_64BIT;
|
caps |= Peer::PID_64BIT;
|
||||||
caps |= Peer::NEW_CACHE_STRATEGY;
|
caps |= Peer::NEW_CACHE_STRATEGY;
|
||||||
|
|
||||||
return caps ? SendToChild(MSG_CAPS, peer, 3, caps, 0, 0) : true;
|
return SendToChild(MSG_CAPS, peer, 3, caps, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RemoteSerializer::Listen(const IPAddr& ip, uint16 port, bool expect_ssl,
|
bool RemoteSerializer::Listen(const IPAddr& ip, uint16 port, bool expect_ssl,
|
||||||
|
|
|
@ -28,6 +28,7 @@ public:
|
||||||
idx = rule_counter++;
|
idx = rule_counter++;
|
||||||
location = arg_location;
|
location = arg_location;
|
||||||
active = true;
|
active = true;
|
||||||
|
next = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
~Rule();
|
~Rule();
|
||||||
|
|
|
@ -103,7 +103,7 @@ private:
|
||||||
friend class RuleMatcher;
|
friend class RuleMatcher;
|
||||||
|
|
||||||
struct PatternSet {
|
struct PatternSet {
|
||||||
PatternSet() {}
|
PatternSet() : re() {}
|
||||||
|
|
||||||
// If we're above the 'RE_level' (see RuleMatcher), this
|
// If we're above the 'RE_level' (see RuleMatcher), this
|
||||||
// expr contains all patterns on this node. If we're on
|
// expr contains all patterns on this node. If we're on
|
||||||
|
|
|
@ -20,6 +20,7 @@ public:
|
||||||
|
|
||||||
SerialInfo(const SerialInfo& info)
|
SerialInfo(const SerialInfo& info)
|
||||||
{
|
{
|
||||||
|
chunk = info.chunk;
|
||||||
s = info.s;
|
s = info.s;
|
||||||
may_suspend = info.may_suspend;
|
may_suspend = info.may_suspend;
|
||||||
cache = info.cache;
|
cache = info.cache;
|
||||||
|
|
|
@ -319,7 +319,8 @@ public:
|
||||||
\
|
\
|
||||||
if ( has_it ) \
|
if ( has_it ) \
|
||||||
{ \
|
{ \
|
||||||
info->s->Read(&dst, 0, "has_" #dst); \
|
if ( ! info->s->Read(&dst, 0, "has_" #dst) ) \
|
||||||
|
return false; \
|
||||||
if ( ! dst ) \
|
if ( ! dst ) \
|
||||||
return false; \
|
return false; \
|
||||||
} \
|
} \
|
||||||
|
@ -339,7 +340,11 @@ public:
|
||||||
\
|
\
|
||||||
if ( has_it ) \
|
if ( has_it ) \
|
||||||
{ \
|
{ \
|
||||||
info->s->Read(&dst, 0, "has_" #dst); \
|
if ( ! info->s->Read(&dst, 0, "has_" #dst) ) \
|
||||||
|
{ \
|
||||||
|
delete del; \
|
||||||
|
return 0; \
|
||||||
|
} \
|
||||||
if ( ! dst ) \
|
if ( ! dst ) \
|
||||||
{ \
|
{ \
|
||||||
delete del; \
|
delete del; \
|
||||||
|
|
|
@ -6,8 +6,9 @@
|
||||||
#include "Reporter.h"
|
#include "Reporter.h"
|
||||||
|
|
||||||
SerializationFormat::SerializationFormat()
|
SerializationFormat::SerializationFormat()
|
||||||
|
: output(), output_size(), output_pos(), input(), input_len(), input_pos(),
|
||||||
|
bytes_written(), bytes_read()
|
||||||
{
|
{
|
||||||
output = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SerializationFormat::~SerializationFormat()
|
SerializationFormat::~SerializationFormat()
|
||||||
|
|
|
@ -136,7 +136,14 @@ bool Serializer::Serialize(SerialInfo* info, const char* func, val_list* args)
|
||||||
Write(network_time, "time");
|
Write(network_time, "time");
|
||||||
Write(a, "len");
|
Write(a, "len");
|
||||||
|
|
||||||
loop_over_list(*args, i) (*args)[i]->Serialize(info);
|
loop_over_list(*args, i)
|
||||||
|
{
|
||||||
|
if ( ! (*args)[i]->Serialize(info) )
|
||||||
|
{
|
||||||
|
Error("failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
WriteCloseTag("call");
|
WriteCloseTag("call");
|
||||||
WriteSeparator();
|
WriteSeparator();
|
||||||
|
@ -1032,6 +1039,7 @@ void ConversionSerializer::GotPacket(Packet* p)
|
||||||
}
|
}
|
||||||
|
|
||||||
EventPlayer::EventPlayer(const char* file)
|
EventPlayer::EventPlayer(const char* file)
|
||||||
|
: stream_time(), replay_time(), ne_time(), ne_handler(), ne_args()
|
||||||
{
|
{
|
||||||
if ( ! OpenFile(file, true) || fd < 0 )
|
if ( ! OpenFile(file, true) || fd < 0 )
|
||||||
Error(fmt("event replayer: cannot open %s", file));
|
Error(fmt("event replayer: cannot open %s", file));
|
||||||
|
|
|
@ -403,6 +403,7 @@ public:
|
||||||
hdr_size = 0;
|
hdr_size = 0;
|
||||||
free = arg_free;
|
free = arg_free;
|
||||||
tag = arg_tag;
|
tag = arg_tag;
|
||||||
|
link_type = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
~Packet()
|
~Packet()
|
||||||
|
|
|
@ -55,15 +55,12 @@ struct SessionStats {
|
||||||
class TimerMgrExpireTimer : public Timer {
|
class TimerMgrExpireTimer : public Timer {
|
||||||
public:
|
public:
|
||||||
TimerMgrExpireTimer(double t, TimerMgr* arg_mgr)
|
TimerMgrExpireTimer(double t, TimerMgr* arg_mgr)
|
||||||
: Timer(t, TIMER_TIMERMGR_EXPIRE)
|
: Timer(t, TIMER_TIMERMGR_EXPIRE), mgr(arg_mgr)
|
||||||
{
|
{ }
|
||||||
mgr = arg_mgr;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void Dispatch(double t, int is_expire);
|
virtual void Dispatch(double t, int is_expire);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
double interval;
|
|
||||||
TimerMgr* mgr;
|
TimerMgr* mgr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
#include "Reporter.h"
|
#include "Reporter.h"
|
||||||
|
|
||||||
BroSubstring::BroSubstring(const BroSubstring& bst)
|
BroSubstring::BroSubstring(const BroSubstring& bst)
|
||||||
: BroString((const BroString&) bst), _new(bst._new)
|
: BroString((const BroString&) bst), _num(), _new(bst._new)
|
||||||
{
|
{
|
||||||
for ( BSSAlignVecCIt it = bst._aligns.begin(); it != bst._aligns.end(); ++it )
|
for ( BSSAlignVecCIt it = bst._aligns.begin(); it != bst._aligns.end(); ++it )
|
||||||
_aligns.push_back(*it);
|
_aligns.push_back(*it);
|
||||||
|
|
|
@ -42,10 +42,10 @@ public:
|
||||||
typedef BSSAlignVec::const_iterator BSSAlignVecCIt;
|
typedef BSSAlignVec::const_iterator BSSAlignVecCIt;
|
||||||
|
|
||||||
BroSubstring(const string& string)
|
BroSubstring(const string& string)
|
||||||
: BroString(string), _new(false) { }
|
: BroString(string), _num(), _new(false) { }
|
||||||
|
|
||||||
BroSubstring(const BroString& string)
|
BroSubstring(const BroString& string)
|
||||||
: BroString(string), _new(false) { }
|
: BroString(string), _num(), _new(false) { }
|
||||||
|
|
||||||
BroSubstring(const BroSubstring& bst);
|
BroSubstring(const BroSubstring& bst);
|
||||||
|
|
||||||
|
|
|
@ -399,6 +399,7 @@ PacketProfiler::PacketProfiler(unsigned int mode, double freq,
|
||||||
last_Utime = last_Stime = last_Rtime = 0.0;
|
last_Utime = last_Stime = last_Rtime = 0.0;
|
||||||
last_timestamp = time = 0.0;
|
last_timestamp = time = 0.0;
|
||||||
pkt_cnt = byte_cnt = 0;
|
pkt_cnt = byte_cnt = 0;
|
||||||
|
last_mem = 0;
|
||||||
|
|
||||||
file->Write("time dt npkts nbytes dRtime dUtime dStime dmem\n");
|
file->Write("time dt npkts nbytes dRtime dUtime dStime dmem\n");
|
||||||
}
|
}
|
||||||
|
|
12
src/Stats.h
12
src/Stats.h
|
@ -29,27 +29,19 @@ public:
|
||||||
// The constructor takes some way of identifying the segment.
|
// The constructor takes some way of identifying the segment.
|
||||||
SegmentProfiler(SegmentStatsReporter* arg_reporter,
|
SegmentProfiler(SegmentStatsReporter* arg_reporter,
|
||||||
const char* arg_name)
|
const char* arg_name)
|
||||||
|
: reporter(arg_reporter), name(arg_name), loc(), initial_rusage()
|
||||||
{
|
{
|
||||||
reporter = arg_reporter;
|
|
||||||
if ( reporter )
|
if ( reporter )
|
||||||
{
|
|
||||||
name = arg_name;
|
|
||||||
loc = 0;
|
|
||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
SegmentProfiler(SegmentStatsReporter* arg_reporter,
|
SegmentProfiler(SegmentStatsReporter* arg_reporter,
|
||||||
const Location* arg_loc)
|
const Location* arg_loc)
|
||||||
|
: reporter(arg_reporter), name(), loc(arg_loc), initial_rusage()
|
||||||
{
|
{
|
||||||
reporter = arg_reporter;
|
|
||||||
if ( reporter )
|
if ( reporter )
|
||||||
{
|
|
||||||
name = 0;
|
|
||||||
loc = arg_loc;
|
|
||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
~SegmentProfiler()
|
~SegmentProfiler()
|
||||||
{
|
{
|
||||||
|
|
|
@ -1218,9 +1218,8 @@ Val* ForStmt::DoExec(Frame* f, Val* v, stmt_flow_type& flow) const
|
||||||
const PDict(TableEntryVal)* loop_vals = tv->AsTable();
|
const PDict(TableEntryVal)* loop_vals = tv->AsTable();
|
||||||
|
|
||||||
HashKey* k;
|
HashKey* k;
|
||||||
TableEntryVal* iter_val;
|
|
||||||
IterCookie* c = loop_vals->InitForIteration();
|
IterCookie* c = loop_vals->InitForIteration();
|
||||||
while ( (iter_val = loop_vals->NextEntry(k, c)) )
|
while ( loop_vals->NextEntry(k, c) )
|
||||||
{
|
{
|
||||||
ListVal* ind_lv = tv->RecoverIndex(k);
|
ListVal* ind_lv = tv->RecoverIndex(k);
|
||||||
delete k;
|
delete k;
|
||||||
|
|
|
@ -179,7 +179,8 @@ unsigned int BroType::MemoryAllocation() const
|
||||||
bool BroType::Serialize(SerialInfo* info) const
|
bool BroType::Serialize(SerialInfo* info) const
|
||||||
{
|
{
|
||||||
// We always send full types (see below).
|
// We always send full types (see below).
|
||||||
SERIALIZE(true);
|
if ( ! SERIALIZE(true) )
|
||||||
|
return false;
|
||||||
|
|
||||||
bool ret = SerialObj::Serialize(info);
|
bool ret = SerialObj::Serialize(info);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -1563,10 +1564,8 @@ bool EnumType::DoUnserialize(UnserialInfo* info)
|
||||||
}
|
}
|
||||||
|
|
||||||
VectorType::VectorType(BroType* element_type)
|
VectorType::VectorType(BroType* element_type)
|
||||||
: BroType(TYPE_VECTOR)
|
: BroType(TYPE_VECTOR), yield_type(element_type)
|
||||||
{
|
{
|
||||||
if ( element_type )
|
|
||||||
yield_type = element_type;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VectorType::~VectorType()
|
VectorType::~VectorType()
|
||||||
|
|
38
src/Val.cc
38
src/Val.cc
|
@ -81,7 +81,9 @@ Val* Val::Clone() const
|
||||||
SerialInfo sinfo(&ss);
|
SerialInfo sinfo(&ss);
|
||||||
sinfo.cache = false;
|
sinfo.cache = false;
|
||||||
|
|
||||||
this->Serialize(&sinfo);
|
if ( ! this->Serialize(&sinfo) )
|
||||||
|
return 0;
|
||||||
|
|
||||||
char* data;
|
char* data;
|
||||||
uint32 len = form->EndWrite(&data);
|
uint32 len = form->EndWrite(&data);
|
||||||
form->StartRead(data, len);
|
form->StartRead(data, len);
|
||||||
|
@ -1656,8 +1658,7 @@ int TableVal::RemoveFrom(Val* val) const
|
||||||
IterCookie* c = tbl->InitForIteration();
|
IterCookie* c = tbl->InitForIteration();
|
||||||
|
|
||||||
HashKey* k;
|
HashKey* k;
|
||||||
TableEntryVal* v;
|
while ( tbl->NextEntry(k, c) )
|
||||||
while ( (v = tbl->NextEntry(k, c)) )
|
|
||||||
{
|
{
|
||||||
Val* index = RecoverIndex(k);
|
Val* index = RecoverIndex(k);
|
||||||
|
|
||||||
|
@ -1955,8 +1956,7 @@ ListVal* TableVal::ConvertToList(TypeTag t) const
|
||||||
IterCookie* c = tbl->InitForIteration();
|
IterCookie* c = tbl->InitForIteration();
|
||||||
|
|
||||||
HashKey* k;
|
HashKey* k;
|
||||||
TableEntryVal* v;
|
while ( tbl->NextEntry(k, c) )
|
||||||
while ( (v = tbl->NextEntry(k, c)) )
|
|
||||||
{
|
{
|
||||||
ListVal* index = table_hash->RecoverVals(k);
|
ListVal* index = table_hash->RecoverVals(k);
|
||||||
|
|
||||||
|
@ -2162,7 +2162,7 @@ void TableVal::DoExpire(double t)
|
||||||
|
|
||||||
else if ( v->ExpireAccessTime() + expire_time < t )
|
else if ( v->ExpireAccessTime() + expire_time < t )
|
||||||
{
|
{
|
||||||
Val* val = v ? v->Value() : 0;
|
Val* val = v->Value();
|
||||||
|
|
||||||
if ( expire_expr )
|
if ( expire_expr )
|
||||||
{
|
{
|
||||||
|
@ -2328,7 +2328,7 @@ bool TableVal::DoSerialize(SerialInfo* info) const
|
||||||
else
|
else
|
||||||
reporter->InternalError("unknown continuation state");
|
reporter->InternalError("unknown continuation state");
|
||||||
|
|
||||||
HashKey* k;
|
HashKey* k = 0;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
assert((!info->cont.ChildSuspended()) || state->v);
|
assert((!info->cont.ChildSuspended()) || state->v);
|
||||||
|
@ -2341,12 +2341,21 @@ bool TableVal::DoSerialize(SerialInfo* info) const
|
||||||
if ( ! state->c )
|
if ( ! state->c )
|
||||||
{
|
{
|
||||||
// No next one.
|
// No next one.
|
||||||
SERIALIZE(false);
|
if ( ! SERIALIZE(false) )
|
||||||
|
{
|
||||||
|
delete k;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// There's a value coming.
|
// There's a value coming.
|
||||||
SERIALIZE(true);
|
if ( ! SERIALIZE(true) )
|
||||||
|
{
|
||||||
|
delete k;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if ( state->v->Value() )
|
if ( state->v->Value() )
|
||||||
state->v->Ref();
|
state->v->Ref();
|
||||||
|
@ -2563,6 +2572,7 @@ unsigned int TableVal::MemoryAllocation() const
|
||||||
|
|
||||||
RecordVal::RecordVal(RecordType* t) : MutableVal(t)
|
RecordVal::RecordVal(RecordType* t) : MutableVal(t)
|
||||||
{
|
{
|
||||||
|
origin = 0;
|
||||||
record_type = t;
|
record_type = t;
|
||||||
int n = record_type->NumFields();
|
int n = record_type->NumFields();
|
||||||
val_list* vl = val.val_list_val = new val_list(n);
|
val_list* vl = val.val_list_val = new val_list(n);
|
||||||
|
@ -2670,6 +2680,16 @@ Val* RecordVal::LookupWithDefault(int field) const
|
||||||
return record_type->FieldDefault(field);
|
return record_type->FieldDefault(field);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Val* RecordVal::Lookup(const char* field, bool with_default) const
|
||||||
|
{
|
||||||
|
int idx = record_type->FieldOffset(field);
|
||||||
|
|
||||||
|
if ( idx < 0 )
|
||||||
|
reporter->InternalError("missing record field: %s", field);
|
||||||
|
|
||||||
|
return with_default ? LookupWithDefault(idx) : Lookup(idx);
|
||||||
|
}
|
||||||
|
|
||||||
RecordVal* RecordVal::CoerceTo(const RecordType* t, Val* aggr, bool allow_orphaning) const
|
RecordVal* RecordVal::CoerceTo(const RecordType* t, Val* aggr, bool allow_orphaning) const
|
||||||
{
|
{
|
||||||
if ( ! record_promotion_compatible(t->AsRecordType(), Type()->AsRecordType()) )
|
if ( ! record_promotion_compatible(t->AsRecordType(), Type()->AsRecordType()) )
|
||||||
|
|
13
src/Val.h
13
src/Val.h
|
@ -466,7 +466,7 @@ public:
|
||||||
protected:
|
protected:
|
||||||
MutableVal(BroType* t) : Val(t)
|
MutableVal(BroType* t) : Val(t)
|
||||||
{ props = 0; id = 0; last_modified = SerialObj::ALWAYS; }
|
{ props = 0; id = 0; last_modified = SerialObj::ALWAYS; }
|
||||||
MutableVal() { id = 0; last_modified = SerialObj::ALWAYS; }
|
MutableVal() { props = 0; id = 0; last_modified = SerialObj::ALWAYS; }
|
||||||
~MutableVal();
|
~MutableVal();
|
||||||
|
|
||||||
friend class ID;
|
friend class ID;
|
||||||
|
@ -895,6 +895,17 @@ public:
|
||||||
Val* Lookup(int field) const; // Does not Ref() value.
|
Val* Lookup(int field) const; // Does not Ref() value.
|
||||||
Val* LookupWithDefault(int field) const; // Does Ref() value.
|
Val* LookupWithDefault(int field) const; // Does Ref() value.
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Looks up the value of a field by field name. If the field doesn't
|
||||||
|
* exist in the record type, it's an internal error: abort.
|
||||||
|
* @param field name of field to lookup.
|
||||||
|
* @param with_default whether to rely on field's &default attribute when
|
||||||
|
* the field has yet to be initialized.
|
||||||
|
* @return the value in field \a field. It is Ref()'d only if
|
||||||
|
* \a with_default is true.
|
||||||
|
*/
|
||||||
|
Val* Lookup(const char* field, bool with_default = false) const;
|
||||||
|
|
||||||
void Describe(ODesc* d) const;
|
void Describe(ODesc* d) const;
|
||||||
|
|
||||||
// This is an experiment to associate a BroObj within the
|
// This is an experiment to associate a BroObj within the
|
||||||
|
|
|
@ -20,7 +20,7 @@ public:
|
||||||
void Dispatch(double t, int is_expire);
|
void Dispatch(double t, int is_expire);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
AnalyzerTimer() {}
|
AnalyzerTimer() : analyzer(), timer(), do_expire() {}
|
||||||
|
|
||||||
void Init(Analyzer* analyzer, analyzer_timer_func timer, int do_expire);
|
void Init(Analyzer* analyzer, analyzer_timer_func timer, int do_expire);
|
||||||
|
|
||||||
|
@ -124,6 +124,7 @@ void Analyzer::CtorInit(const Tag& arg_tag, Connection* arg_conn)
|
||||||
tag = arg_tag;
|
tag = arg_tag;
|
||||||
id = ++id_counter;
|
id = ++id_counter;
|
||||||
protocol_confirmed = false;
|
protocol_confirmed = false;
|
||||||
|
timers_canceled = false;
|
||||||
skip = false;
|
skip = false;
|
||||||
finished = false;
|
finished = false;
|
||||||
removing = false;
|
removing = false;
|
||||||
|
|
|
@ -79,7 +79,7 @@ flow AYIYA_Flow
|
||||||
|
|
||||||
sessions->DoNextInnerPacket(network_time(), 0, inner, e, ec);
|
sessions->DoNextInnerPacket(network_time(), 0, inner, e, ec);
|
||||||
|
|
||||||
return (result == 0) ? true : false;
|
return true;
|
||||||
%}
|
%}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
using namespace analyzer::conn_size;
|
using namespace analyzer::conn_size;
|
||||||
|
|
||||||
ConnSize_Analyzer::ConnSize_Analyzer(Connection* c)
|
ConnSize_Analyzer::ConnSize_Analyzer(Connection* c)
|
||||||
: Analyzer("CONNSIZE", c)
|
: Analyzer("CONNSIZE", c),
|
||||||
|
orig_bytes(), resp_bytes(), orig_pkts(), resp_pkts()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,17 +55,19 @@ void ConnSize_Analyzer::DeliverPacket(int len, const u_char* data, bool is_orig,
|
||||||
void ConnSize_Analyzer::UpdateConnVal(RecordVal *conn_val)
|
void ConnSize_Analyzer::UpdateConnVal(RecordVal *conn_val)
|
||||||
{
|
{
|
||||||
// RecordType *connection_type is decleared in NetVar.h
|
// RecordType *connection_type is decleared in NetVar.h
|
||||||
int orig_endp_idx = connection_type->FieldOffset("orig");
|
RecordVal *orig_endp = conn_val->Lookup("orig")->AsRecordVal();
|
||||||
int resp_endp_idx = connection_type->FieldOffset("resp");
|
RecordVal *resp_endp = conn_val->Lookup("resp")->AsRecordVal();
|
||||||
RecordVal *orig_endp = conn_val->Lookup(orig_endp_idx)->AsRecordVal();
|
|
||||||
RecordVal *resp_endp = conn_val->Lookup(resp_endp_idx)->AsRecordVal();
|
|
||||||
|
|
||||||
// endpoint is the RecordType from NetVar.h
|
// endpoint is the RecordType from NetVar.h
|
||||||
// TODO: or orig_endp->Type()->AsRecordVal()->FieldOffset()
|
|
||||||
int pktidx = endpoint->FieldOffset("num_pkts");
|
int pktidx = endpoint->FieldOffset("num_pkts");
|
||||||
int bytesidx = endpoint->FieldOffset("num_bytes_ip");
|
int bytesidx = endpoint->FieldOffset("num_bytes_ip");
|
||||||
|
|
||||||
// TODO: error handling?
|
if ( pktidx < 0 )
|
||||||
|
reporter->InternalError("'endpoint' record missing 'num_pkts' field");
|
||||||
|
|
||||||
|
if ( bytesidx < 0 )
|
||||||
|
reporter->InternalError("'endpoint' record missing 'num_bytes_ip' field");
|
||||||
|
|
||||||
orig_endp->Assign(pktidx, new Val(orig_pkts, TYPE_COUNT));
|
orig_endp->Assign(pktidx, new Val(orig_pkts, TYPE_COUNT));
|
||||||
orig_endp->Assign(bytesidx, new Val(orig_bytes, TYPE_COUNT));
|
orig_endp->Assign(bytesidx, new Val(orig_bytes, TYPE_COUNT));
|
||||||
resp_endp->Assign(pktidx, new Val(resp_pkts, TYPE_COUNT));
|
resp_endp->Assign(pktidx, new Val(resp_pkts, TYPE_COUNT));
|
||||||
|
|
|
@ -894,6 +894,7 @@ DNS_MsgInfo::DNS_MsgInfo(DNS_RawMsgHdr* hdr, int arg_is_query)
|
||||||
|
|
||||||
answer_type = DNS_QUESTION;
|
answer_type = DNS_QUESTION;
|
||||||
skip_event = 0;
|
skip_event = 0;
|
||||||
|
tsig = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DNS_MsgInfo::~DNS_MsgInfo()
|
DNS_MsgInfo::~DNS_MsgInfo()
|
||||||
|
@ -1002,7 +1003,7 @@ Contents_DNS::Contents_DNS(Connection* conn, bool orig,
|
||||||
interp = arg_interp;
|
interp = arg_interp;
|
||||||
|
|
||||||
msg_buf = 0;
|
msg_buf = 0;
|
||||||
buf_n = msg_size = 0;
|
buf_n = buf_len = msg_size = 0;
|
||||||
state = DNS_LEN_HI;
|
state = DNS_LEN_HI;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -144,7 +144,6 @@ public:
|
||||||
// More values for spesific DNS types.
|
// More values for spesific DNS types.
|
||||||
// struct EDNS_ADDITIONAL* edns;
|
// struct EDNS_ADDITIONAL* edns;
|
||||||
|
|
||||||
int tsig_init;
|
|
||||||
struct TSIG_DATA* tsig;
|
struct TSIG_DATA* tsig;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -534,6 +534,7 @@ HTTP_Message::HTTP_Message(HTTP_Analyzer* arg_analyzer,
|
||||||
top_level = new HTTP_Entity(this, 0, expect_body);
|
top_level = new HTTP_Entity(this, 0, expect_body);
|
||||||
BeginEntity(top_level);
|
BeginEntity(top_level);
|
||||||
|
|
||||||
|
buffer_offset = buffer_size = 0;
|
||||||
data_buffer = 0;
|
data_buffer = 0;
|
||||||
total_buffer_size = 0;
|
total_buffer_size = 0;
|
||||||
|
|
||||||
|
|
|
@ -17,11 +17,10 @@
|
||||||
using namespace analyzer::icmp;
|
using namespace analyzer::icmp;
|
||||||
|
|
||||||
ICMP_Analyzer::ICMP_Analyzer(Connection* c)
|
ICMP_Analyzer::ICMP_Analyzer(Connection* c)
|
||||||
: TransportLayerAnalyzer("ICMP", c)
|
: TransportLayerAnalyzer("ICMP", c),
|
||||||
|
icmp_conn_val(), type(), code(), request_len(-1), reply_len(-1)
|
||||||
{
|
{
|
||||||
icmp_conn_val = 0;
|
|
||||||
c->SetInactivityTimeout(icmp_inactivity_timeout);
|
c->SetInactivityTimeout(icmp_inactivity_timeout);
|
||||||
request_len = reply_len = -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICMP_Analyzer::Done()
|
void ICMP_Analyzer::Done()
|
||||||
|
@ -440,10 +439,8 @@ void ICMP_Analyzer::Describe(ODesc* d) const
|
||||||
|
|
||||||
void ICMP_Analyzer::UpdateConnVal(RecordVal *conn_val)
|
void ICMP_Analyzer::UpdateConnVal(RecordVal *conn_val)
|
||||||
{
|
{
|
||||||
int orig_endp_idx = connection_type->FieldOffset("orig");
|
RecordVal *orig_endp = conn_val->Lookup("orig")->AsRecordVal();
|
||||||
int resp_endp_idx = connection_type->FieldOffset("resp");
|
RecordVal *resp_endp = conn_val->Lookup("resp")->AsRecordVal();
|
||||||
RecordVal *orig_endp = conn_val->Lookup(orig_endp_idx)->AsRecordVal();
|
|
||||||
RecordVal *resp_endp = conn_val->Lookup(resp_endp_idx)->AsRecordVal();
|
|
||||||
|
|
||||||
UpdateEndpointVal(orig_endp, 1);
|
UpdateEndpointVal(orig_endp, 1);
|
||||||
UpdateEndpointVal(resp_endp, 0);
|
UpdateEndpointVal(resp_endp, 0);
|
||||||
|
|
|
@ -25,7 +25,7 @@ static RE_Matcher* re_login_timeouts;
|
||||||
static RE_Matcher* init_RE(ListVal* l);
|
static RE_Matcher* init_RE(ListVal* l);
|
||||||
|
|
||||||
Login_Analyzer::Login_Analyzer(const char* name, Connection* conn)
|
Login_Analyzer::Login_Analyzer(const char* name, Connection* conn)
|
||||||
: tcp::TCP_ApplicationAnalyzer(name, conn)
|
: tcp::TCP_ApplicationAnalyzer(name, conn), user_text()
|
||||||
{
|
{
|
||||||
state = LOGIN_STATE_AUTHENTICATE;
|
state = LOGIN_STATE_AUTHENTICATE;
|
||||||
num_user_lines_seen = lines_scanned = 0;
|
num_user_lines_seen = lines_scanned = 0;
|
||||||
|
|
|
@ -364,14 +364,11 @@ void TelnetBinaryOption::InconsistentOption(unsigned int /* type */)
|
||||||
|
|
||||||
|
|
||||||
NVT_Analyzer::NVT_Analyzer(Connection* conn, bool orig)
|
NVT_Analyzer::NVT_Analyzer(Connection* conn, bool orig)
|
||||||
: tcp::ContentLine_Analyzer("NVT", conn, orig)
|
: tcp::ContentLine_Analyzer("NVT", conn, orig),
|
||||||
|
peer(), pending_IAC(), IAC_pos(), is_suboption(), last_was_IAC(),
|
||||||
|
binary_mode(), encrypting_mode(), authentication_has_been_accepted(),
|
||||||
|
auth_name(), options(), num_options()
|
||||||
{
|
{
|
||||||
peer = 0;
|
|
||||||
is_suboption = last_was_IAC = pending_IAC = 0;
|
|
||||||
IAC_pos = 0;
|
|
||||||
num_options = 0;
|
|
||||||
authentication_has_been_accepted = encrypting_mode = binary_mode = 0;
|
|
||||||
auth_name = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NVT_Analyzer::~NVT_Analyzer()
|
NVT_Analyzer::~NVT_Analyzer()
|
||||||
|
|
|
@ -22,7 +22,10 @@ Contents_Rsh_Analyzer::Contents_Rsh_Analyzer(Connection* conn, bool orig,
|
||||||
if ( orig )
|
if ( orig )
|
||||||
state = save_state = RSH_FIRST_NULL;
|
state = save_state = RSH_FIRST_NULL;
|
||||||
else
|
else
|
||||||
|
{
|
||||||
state = RSH_LINE_MODE;
|
state = RSH_LINE_MODE;
|
||||||
|
save_state = RSH_UNKNOWN;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Contents_Rsh_Analyzer::~Contents_Rsh_Analyzer()
|
Contents_Rsh_Analyzer::~Contents_Rsh_Analyzer()
|
||||||
|
|
|
@ -1257,7 +1257,7 @@ TableVal* MIME_Message::BuildHeaderTable(MIME_HeaderList& hlist)
|
||||||
}
|
}
|
||||||
|
|
||||||
MIME_Mail::MIME_Mail(analyzer::Analyzer* mail_analyzer, int buf_size)
|
MIME_Mail::MIME_Mail(analyzer::Analyzer* mail_analyzer, int buf_size)
|
||||||
: MIME_Message(mail_analyzer)
|
: MIME_Message(mail_analyzer), md5_hash()
|
||||||
{
|
{
|
||||||
analyzer = mail_analyzer;
|
analyzer = mail_analyzer;
|
||||||
|
|
||||||
|
@ -1280,12 +1280,13 @@ MIME_Mail::MIME_Mail(analyzer::Analyzer* mail_analyzer, int buf_size)
|
||||||
if ( mime_content_hash )
|
if ( mime_content_hash )
|
||||||
{
|
{
|
||||||
compute_content_hash = 1;
|
compute_content_hash = 1;
|
||||||
content_hash_length = 0;
|
|
||||||
md5_init(&md5_hash);
|
md5_init(&md5_hash);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
compute_content_hash = 0;
|
compute_content_hash = 0;
|
||||||
|
|
||||||
|
content_hash_length = 0;
|
||||||
|
|
||||||
top_level = new MIME_Entity(this, 0); // to be changed to MIME_Mail
|
top_level = new MIME_Entity(this, 0); // to be changed to MIME_Mail
|
||||||
BeginEntity(top_level);
|
BeginEntity(top_level);
|
||||||
}
|
}
|
||||||
|
|
|
@ -247,7 +247,6 @@ protected:
|
||||||
int max_chunk_length;
|
int max_chunk_length;
|
||||||
int buffer_start;
|
int buffer_start;
|
||||||
int data_start;
|
int data_start;
|
||||||
int buffer_offset;
|
|
||||||
int compute_content_hash;
|
int compute_content_hash;
|
||||||
int content_hash_length;
|
int content_hash_length;
|
||||||
MD5_CTX md5_hash;
|
MD5_CTX md5_hash;
|
||||||
|
|
|
@ -346,7 +346,7 @@ Contents_NetbiosSSN::Contents_NetbiosSSN(Connection* conn, bool orig,
|
||||||
interp = arg_interp;
|
interp = arg_interp;
|
||||||
type = flags = msg_size = 0;
|
type = flags = msg_size = 0;
|
||||||
msg_buf = 0;
|
msg_buf = 0;
|
||||||
buf_n = msg_size = 0;
|
buf_n = buf_len = msg_size = 0;
|
||||||
state = NETBIOS_SSN_TYPE;
|
state = NETBIOS_SSN_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,9 +7,8 @@
|
||||||
using namespace analyzer::pia;
|
using namespace analyzer::pia;
|
||||||
|
|
||||||
PIA::PIA(analyzer::Analyzer* arg_as_analyzer)
|
PIA::PIA(analyzer::Analyzer* arg_as_analyzer)
|
||||||
|
: state(INIT), as_analyzer(arg_as_analyzer), conn(), current_packet()
|
||||||
{
|
{
|
||||||
current_packet.data = 0;
|
|
||||||
as_analyzer = arg_as_analyzer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PIA::~PIA()
|
PIA::~PIA()
|
||||||
|
|
|
@ -43,6 +43,9 @@ POP3_Analyzer::POP3_Analyzer(Connection* conn)
|
||||||
multiLine = false;
|
multiLine = false;
|
||||||
backOff = false;
|
backOff = false;
|
||||||
|
|
||||||
|
lastRequiredCommand = 0;
|
||||||
|
authLines = 0;
|
||||||
|
|
||||||
mail = 0;
|
mail = 0;
|
||||||
|
|
||||||
AddSupportAnalyzer(new tcp::ContentLine_Analyzer(conn, true));
|
AddSupportAnalyzer(new tcp::ContentLine_Analyzer(conn, true));
|
||||||
|
|
|
@ -679,10 +679,9 @@ void Contents_RPC::DeliverStream(int len, const u_char* data, bool orig)
|
||||||
|
|
||||||
RPC_Analyzer::RPC_Analyzer(const char* name, Connection* conn,
|
RPC_Analyzer::RPC_Analyzer(const char* name, Connection* conn,
|
||||||
RPC_Interpreter* arg_interp)
|
RPC_Interpreter* arg_interp)
|
||||||
: tcp::TCP_ApplicationAnalyzer(name, conn)
|
: tcp::TCP_ApplicationAnalyzer(name, conn),
|
||||||
|
nterp(arg_interp), orig_rpc(), resp_rpc()
|
||||||
{
|
{
|
||||||
interp = arg_interp;
|
|
||||||
|
|
||||||
if ( Conn()->ConnTransport() == TRANSPORT_UDP )
|
if ( Conn()->ConnTransport() == TRANSPORT_UDP )
|
||||||
ADD_ANALYZER_TIMER(&RPC_Analyzer::ExpireTimer,
|
ADD_ANALYZER_TIMER(&RPC_Analyzer::ExpireTimer,
|
||||||
network_time + rpc_timeout, 1, TIMER_RPC_EXPIRE);
|
network_time + rpc_timeout, 1, TIMER_RPC_EXPIRE);
|
||||||
|
|
|
@ -100,6 +100,9 @@ static int lookup_IPC_name(BroString* name)
|
||||||
SMB_Session::SMB_Session(analyzer::Analyzer* arg_analyzer)
|
SMB_Session::SMB_Session(analyzer::Analyzer* arg_analyzer)
|
||||||
{
|
{
|
||||||
analyzer = arg_analyzer;
|
analyzer = arg_analyzer;
|
||||||
|
req_cmd = 0;
|
||||||
|
smb_mailslot_prot = false;
|
||||||
|
smb_pipe_prot = false;
|
||||||
dce_rpc_session = 0;
|
dce_rpc_session = 0;
|
||||||
init_SMB_command_name();
|
init_SMB_command_name();
|
||||||
|
|
||||||
|
|
|
@ -1102,11 +1102,8 @@ void TCP_Analyzer::FlipRoles()
|
||||||
|
|
||||||
void TCP_Analyzer::UpdateConnVal(RecordVal *conn_val)
|
void TCP_Analyzer::UpdateConnVal(RecordVal *conn_val)
|
||||||
{
|
{
|
||||||
int orig_endp_idx = connection_type->FieldOffset("orig");
|
RecordVal *orig_endp_val = conn_val->Lookup("orig")->AsRecordVal();
|
||||||
int resp_endp_idx = connection_type->FieldOffset("resp");
|
RecordVal *resp_endp_val = conn_val->Lookup("resp")->AsRecordVal();
|
||||||
|
|
||||||
RecordVal *orig_endp_val = conn_val->Lookup(orig_endp_idx)->AsRecordVal();
|
|
||||||
RecordVal *resp_endp_val = conn_val->Lookup(resp_endp_idx)->AsRecordVal();
|
|
||||||
|
|
||||||
orig_endp_val->Assign(0, new Val(orig->Size(), TYPE_COUNT));
|
orig_endp_val->Assign(0, new Val(orig->Size(), TYPE_COUNT));
|
||||||
orig_endp_val->Assign(1, new Val(int(orig->state), TYPE_COUNT));
|
orig_endp_val->Assign(1, new Val(int(orig->state), TYPE_COUNT));
|
||||||
|
@ -2046,7 +2043,8 @@ RecordVal* TCPStats_Endpoint::BuildStats()
|
||||||
}
|
}
|
||||||
|
|
||||||
TCPStats_Analyzer::TCPStats_Analyzer(Connection* c)
|
TCPStats_Analyzer::TCPStats_Analyzer(Connection* c)
|
||||||
: TCP_ApplicationAnalyzer("TCPSTATS", c)
|
: TCP_ApplicationAnalyzer("TCPSTATS", c),
|
||||||
|
orig_stats(), resp_stats()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,12 +25,15 @@ TCP_Endpoint::TCP_Endpoint(TCP_Analyzer* arg_analyzer, int arg_is_orig)
|
||||||
window_scale = 0;
|
window_scale = 0;
|
||||||
window_seq = window_ack_seq = 0;
|
window_seq = window_ack_seq = 0;
|
||||||
contents_start_seq = 0;
|
contents_start_seq = 0;
|
||||||
|
FIN_seq = 0;
|
||||||
SYN_cnt = FIN_cnt = RST_cnt = 0;
|
SYN_cnt = FIN_cnt = RST_cnt = 0;
|
||||||
did_close = 0;
|
did_close = 0;
|
||||||
contents_file = 0;
|
contents_file = 0;
|
||||||
tcp_analyzer = arg_analyzer;
|
tcp_analyzer = arg_analyzer;
|
||||||
is_orig = arg_is_orig;
|
is_orig = arg_is_orig;
|
||||||
|
|
||||||
|
hist_last_SYN = hist_last_FIN = hist_last_RST = 0;
|
||||||
|
|
||||||
src_addr = is_orig ? tcp_analyzer->Conn()->RespAddr() :
|
src_addr = is_orig ? tcp_analyzer->Conn()->RespAddr() :
|
||||||
tcp_analyzer->Conn()->OrigAddr();
|
tcp_analyzer->Conn()->OrigAddr();
|
||||||
dst_addr = is_orig ? tcp_analyzer->Conn()->OrigAddr() :
|
dst_addr = is_orig ? tcp_analyzer->Conn()->OrigAddr() :
|
||||||
|
|
|
@ -170,13 +170,9 @@ void UDP_Analyzer::DeliverPacket(int len, const u_char* data, bool is_orig,
|
||||||
|
|
||||||
void UDP_Analyzer::UpdateConnVal(RecordVal *conn_val)
|
void UDP_Analyzer::UpdateConnVal(RecordVal *conn_val)
|
||||||
{
|
{
|
||||||
int orig_endp_idx = connection_type->FieldOffset("orig");
|
RecordVal *orig_endp = conn_val->Lookup("orig")->AsRecordVal();
|
||||||
int resp_endp_idx = connection_type->FieldOffset("resp");
|
RecordVal *resp_endp = conn_val->Lookup("resp")->AsRecordVal();
|
||||||
RecordVal *orig_endp = conn_val->Lookup(orig_endp_idx)->AsRecordVal();
|
|
||||||
RecordVal *resp_endp = conn_val->Lookup(resp_endp_idx)->AsRecordVal();
|
|
||||||
|
|
||||||
orig_endp = conn_val->Lookup(orig_endp_idx)->AsRecordVal();
|
|
||||||
resp_endp = conn_val->Lookup(resp_endp_idx)->AsRecordVal();
|
|
||||||
UpdateEndpointVal(orig_endp, 1);
|
UpdateEndpointVal(orig_endp, 1);
|
||||||
UpdateEndpointVal(resp_endp, 0);
|
UpdateEndpointVal(resp_endp, 0);
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ BuiltinFuncArg::BuiltinFuncArg(const char* arg_name, int arg_type)
|
||||||
name = arg_name;
|
name = arg_name;
|
||||||
type = arg_type;
|
type = arg_type;
|
||||||
type_str = "";
|
type_str = "";
|
||||||
|
attr_str = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
BuiltinFuncArg::BuiltinFuncArg(const char* arg_name, const char* arg_type_str,
|
BuiltinFuncArg::BuiltinFuncArg(const char* arg_name, const char* arg_type_str,
|
||||||
|
|
|
@ -20,13 +20,8 @@ DataEvent::DataEvent(RecordVal* args, File* file,
|
||||||
|
|
||||||
file_analysis::Analyzer* DataEvent::Instantiate(RecordVal* args, File* file)
|
file_analysis::Analyzer* DataEvent::Instantiate(RecordVal* args, File* file)
|
||||||
{
|
{
|
||||||
using BifType::Record::Files::AnalyzerArgs;
|
Val* chunk_val = args->Lookup("chunk_event");
|
||||||
|
Val* stream_val = args->Lookup("stream_event");
|
||||||
int chunk_off = AnalyzerArgs->FieldOffset("chunk_event");
|
|
||||||
int stream_off = AnalyzerArgs->FieldOffset("stream_event");
|
|
||||||
|
|
||||||
Val* chunk_val = args->Lookup(chunk_off);
|
|
||||||
Val* stream_val = args->Lookup(stream_off);
|
|
||||||
|
|
||||||
if ( ! chunk_val && ! stream_val ) return 0;
|
if ( ! chunk_val && ! stream_val ) return 0;
|
||||||
|
|
||||||
|
|
|
@ -33,8 +33,7 @@ Extract::~Extract()
|
||||||
|
|
||||||
static Val* get_extract_field_val(RecordVal* args, const char* name)
|
static Val* get_extract_field_val(RecordVal* args, const char* name)
|
||||||
{
|
{
|
||||||
using BifType::Record::Files::AnalyzerArgs;
|
Val* rval = args->Lookup(name);
|
||||||
Val* rval = args->Lookup(AnalyzerArgs->FieldOffset(name));
|
|
||||||
|
|
||||||
if ( ! rval )
|
if ( ! rval )
|
||||||
reporter->Error("File extraction analyzer missing arg field: %s", name);
|
reporter->Error("File extraction analyzer missing arg field: %s", name);
|
||||||
|
|
|
@ -30,7 +30,6 @@ private:
|
||||||
binpac::Unified2::Unified2_Analyzer* interp;
|
binpac::Unified2::Unified2_Analyzer* interp;
|
||||||
|
|
||||||
string filename;
|
string filename;
|
||||||
int fd;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace file_analysis
|
} // namespace file_analysis
|
||||||
|
|
|
@ -84,16 +84,16 @@ public:
|
||||||
|
|
||||||
RecordVal* description;
|
RecordVal* description;
|
||||||
|
|
||||||
Stream();
|
|
||||||
virtual ~Stream();
|
virtual ~Stream();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
Stream(StreamType t);
|
||||||
};
|
};
|
||||||
|
|
||||||
Manager::Stream::Stream()
|
Manager::Stream::Stream(StreamType t)
|
||||||
|
: name(), removed(), stream_type(t), type(), reader(), config(),
|
||||||
|
description()
|
||||||
{
|
{
|
||||||
type = 0;
|
|
||||||
reader = 0;
|
|
||||||
description = 0;
|
|
||||||
removed = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Manager::Stream::~Stream()
|
Manager::Stream::~Stream()
|
||||||
|
@ -154,24 +154,17 @@ public:
|
||||||
~AnalysisStream();
|
~AnalysisStream();
|
||||||
};
|
};
|
||||||
|
|
||||||
Manager::TableStream::TableStream() : Manager::Stream::Stream()
|
Manager::TableStream::TableStream()
|
||||||
|
: Manager::Stream::Stream(TABLE_STREAM),
|
||||||
|
num_idx_fields(), num_val_fields(), want_record(), tab(), rtype(),
|
||||||
|
itype(), currDict(), lastDict(), pred(), event()
|
||||||
{
|
{
|
||||||
stream_type = TABLE_STREAM;
|
|
||||||
|
|
||||||
tab = 0;
|
|
||||||
itype = 0;
|
|
||||||
rtype = 0;
|
|
||||||
|
|
||||||
currDict = 0;
|
|
||||||
lastDict = 0;
|
|
||||||
|
|
||||||
pred = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Manager::EventStream::EventStream() : Manager::Stream::Stream()
|
Manager::EventStream::EventStream()
|
||||||
|
: Manager::Stream::Stream(EVENT_STREAM),
|
||||||
|
event(), fields(), num_fields(), want_record()
|
||||||
{
|
{
|
||||||
fields = 0;
|
|
||||||
stream_type = EVENT_STREAM;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Manager::EventStream::~EventStream()
|
Manager::EventStream::~EventStream()
|
||||||
|
@ -204,9 +197,9 @@ Manager::TableStream::~TableStream()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Manager::AnalysisStream::AnalysisStream() : Manager::Stream::Stream()
|
Manager::AnalysisStream::AnalysisStream()
|
||||||
|
: Manager::Stream::Stream(ANALYSIS_STREAM), file_id()
|
||||||
{
|
{
|
||||||
stream_type = ANALYSIS_STREAM;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Manager::AnalysisStream::~AnalysisStream()
|
Manager::AnalysisStream::~AnalysisStream()
|
||||||
|
@ -296,7 +289,7 @@ bool Manager::CreateStream(Stream* info, RecordVal* description)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Val* name_val = description->LookupWithDefault(rtype->FieldOffset("name"));
|
Val* name_val = description->Lookup("name", true);
|
||||||
string name = name_val->AsString()->CheckString();
|
string name = name_val->AsString()->CheckString();
|
||||||
Unref(name_val);
|
Unref(name_val);
|
||||||
|
|
||||||
|
@ -308,10 +301,10 @@ bool Manager::CreateStream(Stream* info, RecordVal* description)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
EnumVal* reader = description->LookupWithDefault(rtype->FieldOffset("reader"))->AsEnumVal();
|
EnumVal* reader = description->Lookup("reader", true)->AsEnumVal();
|
||||||
|
|
||||||
// get the source ...
|
// get the source ...
|
||||||
Val* sourceval = description->LookupWithDefault(rtype->FieldOffset("source"));
|
Val* sourceval = description->Lookup("source", true);
|
||||||
assert ( sourceval != 0 );
|
assert ( sourceval != 0 );
|
||||||
const BroString* bsource = sourceval->AsString();
|
const BroString* bsource = sourceval->AsString();
|
||||||
string source((const char*) bsource->Bytes(), bsource->Len());
|
string source((const char*) bsource->Bytes(), bsource->Len());
|
||||||
|
@ -321,7 +314,7 @@ bool Manager::CreateStream(Stream* info, RecordVal* description)
|
||||||
rinfo.source = copy_string(source.c_str());
|
rinfo.source = copy_string(source.c_str());
|
||||||
rinfo.name = copy_string(name.c_str());
|
rinfo.name = copy_string(name.c_str());
|
||||||
|
|
||||||
EnumVal* mode = description->LookupWithDefault(rtype->FieldOffset("mode"))->AsEnumVal();
|
EnumVal* mode = description->Lookup("mode", true)->AsEnumVal();
|
||||||
switch ( mode->InternalInt() )
|
switch ( mode->InternalInt() )
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -342,7 +335,7 @@ bool Manager::CreateStream(Stream* info, RecordVal* description)
|
||||||
|
|
||||||
Unref(mode);
|
Unref(mode);
|
||||||
|
|
||||||
Val* config = description->LookupWithDefault(rtype->FieldOffset("config"));
|
Val* config = description->Lookup("config", true);
|
||||||
info->config = config->AsTableVal(); // ref'd by LookupWithDefault
|
info->config = config->AsTableVal(); // ref'd by LookupWithDefault
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -401,11 +394,11 @@ bool Manager::CreateEventStream(RecordVal* fval)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
RecordType *fields = fval->LookupWithDefault(rtype->FieldOffset("fields"))->AsType()->AsTypeType()->Type()->AsRecordType();
|
RecordType *fields = fval->Lookup("fields", true)->AsType()->AsTypeType()->Type()->AsRecordType();
|
||||||
|
|
||||||
Val *want_record = fval->LookupWithDefault(rtype->FieldOffset("want_record"));
|
Val *want_record = fval->Lookup("want_record", true);
|
||||||
|
|
||||||
Val* event_val = fval->LookupWithDefault(rtype->FieldOffset("ev"));
|
Val* event_val = fval->Lookup("ev", true);
|
||||||
Func* event = event_val->AsFunc();
|
Func* event = event_val->AsFunc();
|
||||||
Unref(event_val);
|
Unref(event_val);
|
||||||
|
|
||||||
|
@ -547,18 +540,18 @@ bool Manager::CreateTableStream(RecordVal* fval)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Val* pred = fval->LookupWithDefault(rtype->FieldOffset("pred"));
|
Val* pred = fval->Lookup("pred", true);
|
||||||
|
|
||||||
RecordType *idx = fval->LookupWithDefault(rtype->FieldOffset("idx"))->AsType()->AsTypeType()->Type()->AsRecordType();
|
RecordType *idx = fval->Lookup("idx", true)->AsType()->AsTypeType()->Type()->AsRecordType();
|
||||||
RecordType *val = 0;
|
RecordType *val = 0;
|
||||||
|
|
||||||
if ( fval->LookupWithDefault(rtype->FieldOffset("val")) != 0 )
|
if ( fval->Lookup("val", true) != 0 )
|
||||||
{
|
{
|
||||||
val = fval->LookupWithDefault(rtype->FieldOffset("val"))->AsType()->AsTypeType()->Type()->AsRecordType();
|
val = fval->Lookup("val", true)->AsType()->AsTypeType()->Type()->AsRecordType();
|
||||||
Unref(val); // The lookupwithdefault in the if-clause ref'ed val.
|
Unref(val); // The lookupwithdefault in the if-clause ref'ed val.
|
||||||
}
|
}
|
||||||
|
|
||||||
TableVal *dst = fval->LookupWithDefault(rtype->FieldOffset("destination"))->AsTableVal();
|
TableVal *dst = fval->Lookup("destination", true)->AsTableVal();
|
||||||
|
|
||||||
// check if index fields match table description
|
// check if index fields match table description
|
||||||
int num = idx->NumFields();
|
int num = idx->NumFields();
|
||||||
|
@ -588,9 +581,9 @@ bool Manager::CreateTableStream(RecordVal* fval)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Val *want_record = fval->LookupWithDefault(rtype->FieldOffset("want_record"));
|
Val *want_record = fval->Lookup("want_record", true);
|
||||||
|
|
||||||
Val* event_val = fval->LookupWithDefault(rtype->FieldOffset("ev"));
|
Val* event_val = fval->Lookup("ev", true);
|
||||||
Func* event = event_val ? event_val->AsFunc() : 0;
|
Func* event = event_val ? event_val->AsFunc() : 0;
|
||||||
Unref(event_val);
|
Unref(event_val);
|
||||||
|
|
||||||
|
@ -1153,7 +1146,6 @@ int Manager::SendEntryTable(Stream* i, const Value* const *vals)
|
||||||
{
|
{
|
||||||
// just quit and delete everything we created.
|
// just quit and delete everything we created.
|
||||||
delete idxhash;
|
delete idxhash;
|
||||||
delete h;
|
|
||||||
return stream->num_val_fields + stream->num_idx_fields;
|
return stream->num_val_fields + stream->num_idx_fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -163,6 +163,8 @@ ReaderBackend::ReaderBackend(ReaderFrontend* arg_frontend) : MsgThread()
|
||||||
disabled = true; // disabled will be set correcty in init.
|
disabled = true; // disabled will be set correcty in init.
|
||||||
frontend = arg_frontend;
|
frontend = arg_frontend;
|
||||||
info = new ReaderInfo(frontend->Info());
|
info = new ReaderInfo(frontend->Info());
|
||||||
|
num_fields = 0;
|
||||||
|
fields = 0;
|
||||||
|
|
||||||
SetName(frontend->Name());
|
SetName(frontend->Name());
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ using threading::Value;
|
||||||
using threading::Field;
|
using threading::Field;
|
||||||
|
|
||||||
FieldMapping::FieldMapping(const string& arg_name, const TypeTag& arg_type, int arg_position)
|
FieldMapping::FieldMapping(const string& arg_name, const TypeTag& arg_type, int arg_position)
|
||||||
: name(arg_name), type(arg_type)
|
: name(arg_name), type(arg_type), subtype(TYPE_ERROR)
|
||||||
{
|
{
|
||||||
position = arg_position;
|
position = arg_position;
|
||||||
secondary_position = -1;
|
secondary_position = -1;
|
||||||
|
@ -49,6 +49,7 @@ FieldMapping FieldMapping::subType()
|
||||||
Ascii::Ascii(ReaderFrontend *frontend) : ReaderBackend(frontend)
|
Ascii::Ascii(ReaderFrontend *frontend) : ReaderBackend(frontend)
|
||||||
{
|
{
|
||||||
file = 0;
|
file = 0;
|
||||||
|
mtime = 0;
|
||||||
|
|
||||||
separator.assign( (const char*) BifConst::InputAscii::separator->Bytes(),
|
separator.assign( (const char*) BifConst::InputAscii::separator->Bytes(),
|
||||||
BifConst::InputAscii::separator->Len());
|
BifConst::InputAscii::separator->Len());
|
||||||
|
|
|
@ -18,6 +18,7 @@ using threading::Field;
|
||||||
|
|
||||||
Benchmark::Benchmark(ReaderFrontend *frontend) : ReaderBackend(frontend)
|
Benchmark::Benchmark(ReaderFrontend *frontend) : ReaderBackend(frontend)
|
||||||
{
|
{
|
||||||
|
num_lines = 0;
|
||||||
multiplication_factor = double(BifConst::InputBenchmark::factor);
|
multiplication_factor = double(BifConst::InputBenchmark::factor);
|
||||||
autospread = double(BifConst::InputBenchmark::autospread);
|
autospread = double(BifConst::InputBenchmark::autospread);
|
||||||
spread = int(BifConst::InputBenchmark::spread);
|
spread = int(BifConst::InputBenchmark::spread);
|
||||||
|
@ -25,6 +26,7 @@ Benchmark::Benchmark(ReaderFrontend *frontend) : ReaderBackend(frontend)
|
||||||
autospread_time = 0;
|
autospread_time = 0;
|
||||||
stopspreadat = int(BifConst::InputBenchmark::stopspreadat);
|
stopspreadat = int(BifConst::InputBenchmark::stopspreadat);
|
||||||
timedspread = double(BifConst::InputBenchmark::timedspread);
|
timedspread = double(BifConst::InputBenchmark::timedspread);
|
||||||
|
heartbeatstarttime = 0;
|
||||||
heartbeat_interval = double(BifConst::Threading::heartbeat_interval);
|
heartbeat_interval = double(BifConst::Threading::heartbeat_interval);
|
||||||
|
|
||||||
ascii = new AsciiFormatter(this, AsciiFormatter::SeparatorInfo());
|
ascii = new AsciiFormatter(this, AsciiFormatter::SeparatorInfo());
|
||||||
|
|
|
@ -34,6 +34,9 @@ Raw::Raw(ReaderFrontend *frontend) : ReaderBackend(frontend)
|
||||||
{
|
{
|
||||||
file = 0;
|
file = 0;
|
||||||
stderrfile = 0;
|
stderrfile = 0;
|
||||||
|
execute = false;
|
||||||
|
firstrun = true;
|
||||||
|
mtime = 0;
|
||||||
forcekill = false;
|
forcekill = false;
|
||||||
separator.assign( (const char*) BifConst::InputRaw::record_separator->Bytes(),
|
separator.assign( (const char*) BifConst::InputRaw::record_separator->Bytes(),
|
||||||
BifConst::InputRaw::record_separator->Len());
|
BifConst::InputRaw::record_separator->Len());
|
||||||
|
@ -95,6 +98,18 @@ void Raw::ClosePipeEnd(int i)
|
||||||
pipes[i] = -1;
|
pipes[i] = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Raw::SetFDFlags(int fd, int cmd, int flags)
|
||||||
|
{
|
||||||
|
if ( fcntl(fd, cmd, flags) != -1 )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
char buf[256];
|
||||||
|
strerror_r(errno, buf, sizeof(buf));
|
||||||
|
Error(Fmt("failed to set fd flags: %s", buf));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Raw::LockForkMutex()
|
bool Raw::LockForkMutex()
|
||||||
{
|
{
|
||||||
int res = pthread_mutex_lock(&fork_mutex);
|
int res = pthread_mutex_lock(&fork_mutex);
|
||||||
|
@ -200,11 +215,15 @@ bool Raw::Execute()
|
||||||
ClosePipeEnd(stdout_out);
|
ClosePipeEnd(stdout_out);
|
||||||
|
|
||||||
if ( Info().mode == MODE_STREAM )
|
if ( Info().mode == MODE_STREAM )
|
||||||
fcntl(pipes[stdout_in], F_SETFL, O_NONBLOCK);
|
{
|
||||||
|
if ( ! SetFDFlags(pipes[stdout_in], F_SETFL, O_NONBLOCK) )
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
ClosePipeEnd(stdin_in);
|
ClosePipeEnd(stdin_in);
|
||||||
|
|
||||||
if ( stdin_towrite )
|
if ( stdin_towrite )
|
||||||
|
{
|
||||||
// Ya, just always set this to nonblocking. we do not
|
// Ya, just always set this to nonblocking. we do not
|
||||||
// want to block on a program receiving data. Note
|
// want to block on a program receiving data. Note
|
||||||
// that there is a small gotcha with it. More data is
|
// that there is a small gotcha with it. More data is
|
||||||
|
@ -213,14 +232,19 @@ bool Raw::Execute()
|
||||||
// mode_manual where the first write cannot write
|
// mode_manual where the first write cannot write
|
||||||
// everything, the rest will be stuck in a queue that
|
// everything, the rest will be stuck in a queue that
|
||||||
// is never emptied.
|
// is never emptied.
|
||||||
fcntl(pipes[stdin_out], F_SETFL, O_NONBLOCK);
|
if ( ! SetFDFlags(pipes[stdin_out], F_SETFL, O_NONBLOCK) )
|
||||||
|
return false;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
ClosePipeEnd(stdin_out);
|
ClosePipeEnd(stdin_out);
|
||||||
|
|
||||||
ClosePipeEnd(stderr_out);
|
ClosePipeEnd(stderr_out);
|
||||||
|
|
||||||
if ( use_stderr )
|
if ( use_stderr )
|
||||||
fcntl(pipes[stderr_in], F_SETFL, O_NONBLOCK); // true for this too.
|
{
|
||||||
|
if ( ! SetFDFlags(pipes[stderr_in], F_SETFL, O_NONBLOCK) )
|
||||||
|
return false;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
ClosePipeEnd(stderr_in);
|
ClosePipeEnd(stderr_in);
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ClosePipeEnd(int i);
|
void ClosePipeEnd(int i);
|
||||||
|
bool SetFDFlags(int fd, int cmd, int flags);
|
||||||
bool LockForkMutex();
|
bool LockForkMutex();
|
||||||
bool UnlockForkMutex();
|
bool UnlockForkMutex();
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,9 @@ using namespace input::reader;
|
||||||
using threading::Value;
|
using threading::Value;
|
||||||
using threading::Field;
|
using threading::Field;
|
||||||
|
|
||||||
SQLite::SQLite(ReaderFrontend *frontend) : ReaderBackend(frontend)
|
SQLite::SQLite(ReaderFrontend *frontend)
|
||||||
|
: ReaderBackend(frontend),
|
||||||
|
fields(), num_fields(), mode(), started(), query(), db(), st()
|
||||||
{
|
{
|
||||||
set_separator.assign(
|
set_separator.assign(
|
||||||
(const char*) BifConst::LogSQLite::set_separator->Bytes(),
|
(const char*) BifConst::LogSQLite::set_separator->Bytes(),
|
||||||
|
|
|
@ -295,7 +295,7 @@ bool Manager::CreateStream(EnumVal* id, RecordVal* sval)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
RecordType* columns = sval->Lookup(rtype->FieldOffset("columns"))
|
RecordType* columns = sval->Lookup("columns")
|
||||||
->AsType()->AsTypeType()->Type()->AsRecordType();
|
->AsType()->AsTypeType()->Type()->AsRecordType();
|
||||||
|
|
||||||
bool log_attr_present = false;
|
bool log_attr_present = false;
|
||||||
|
@ -322,7 +322,7 @@ bool Manager::CreateStream(EnumVal* id, RecordVal* sval)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Val* event_val = sval->Lookup(rtype->FieldOffset("ev"));
|
Val* event_val = sval->Lookup("ev");
|
||||||
Func* event = event_val ? event_val->AsFunc() : 0;
|
Func* event = event_val ? event_val->AsFunc() : 0;
|
||||||
|
|
||||||
if ( event )
|
if ( event )
|
||||||
|
@ -579,19 +579,18 @@ bool Manager::AddFilter(EnumVal* id, RecordVal* fval)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Find the right writer type.
|
// Find the right writer type.
|
||||||
int idx = rtype->FieldOffset("writer");
|
EnumVal* writer = fval->Lookup("writer", true)->AsEnumVal();
|
||||||
EnumVal* writer = fval->LookupWithDefault(idx)->AsEnumVal();
|
|
||||||
|
|
||||||
// Create a new Filter instance.
|
// Create a new Filter instance.
|
||||||
|
|
||||||
Val* name = fval->LookupWithDefault(rtype->FieldOffset("name"));
|
Val* name = fval->Lookup("name", true);
|
||||||
Val* pred = fval->LookupWithDefault(rtype->FieldOffset("pred"));
|
Val* pred = fval->Lookup("pred", true);
|
||||||
Val* path_func = fval->LookupWithDefault(rtype->FieldOffset("path_func"));
|
Val* path_func = fval->Lookup("path_func", true);
|
||||||
Val* log_local = fval->LookupWithDefault(rtype->FieldOffset("log_local"));
|
Val* log_local = fval->Lookup("log_local", true);
|
||||||
Val* log_remote = fval->LookupWithDefault(rtype->FieldOffset("log_remote"));
|
Val* log_remote = fval->Lookup("log_remote", true);
|
||||||
Val* interv = fval->LookupWithDefault(rtype->FieldOffset("interv"));
|
Val* interv = fval->Lookup("interv", true);
|
||||||
Val* postprocessor = fval->LookupWithDefault(rtype->FieldOffset("postprocessor"));
|
Val* postprocessor = fval->Lookup("postprocessor", true);
|
||||||
Val* config = fval->LookupWithDefault(rtype->FieldOffset("config"));
|
Val* config = fval->Lookup("config", true);
|
||||||
|
|
||||||
Filter* filter = new Filter;
|
Filter* filter = new Filter;
|
||||||
filter->name = name->AsString()->CheckString();
|
filter->name = name->AsString()->CheckString();
|
||||||
|
@ -616,8 +615,8 @@ bool Manager::AddFilter(EnumVal* id, RecordVal* fval)
|
||||||
|
|
||||||
// Build the list of fields that the filter wants included, including
|
// Build the list of fields that the filter wants included, including
|
||||||
// potentially rolling out fields.
|
// potentially rolling out fields.
|
||||||
Val* include = fval->Lookup(rtype->FieldOffset("include"));
|
Val* include = fval->Lookup("include");
|
||||||
Val* exclude = fval->Lookup(rtype->FieldOffset("exclude"));
|
Val* exclude = fval->Lookup("exclude");
|
||||||
|
|
||||||
filter->num_fields = 0;
|
filter->num_fields = 0;
|
||||||
filter->fields = 0;
|
filter->fields = 0;
|
||||||
|
@ -631,7 +630,7 @@ bool Manager::AddFilter(EnumVal* id, RecordVal* fval)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the path for the filter.
|
// Get the path for the filter.
|
||||||
Val* path_val = fval->Lookup(rtype->FieldOffset("path"));
|
Val* path_val = fval->Lookup("path");
|
||||||
|
|
||||||
if ( path_val )
|
if ( path_val )
|
||||||
{
|
{
|
||||||
|
|
|
@ -242,17 +242,6 @@ public:
|
||||||
* Note: Exactly one of the two FinishedRotation() methods must be
|
* Note: Exactly one of the two FinishedRotation() methods must be
|
||||||
* called by a writer's implementation of DoRotate() once rotation
|
* called by a writer's implementation of DoRotate() once rotation
|
||||||
* has finished.
|
* has finished.
|
||||||
*
|
|
||||||
* @param new_name The filename of the rotated file.
|
|
||||||
*
|
|
||||||
* @param old_name The filename of the original file.
|
|
||||||
*
|
|
||||||
* @param open: The timestamp when the original file was opened.
|
|
||||||
*
|
|
||||||
* @param close: The timestamp when the origina file was closed.
|
|
||||||
*
|
|
||||||
* @param terminating: True if the original rotation request occured
|
|
||||||
* due to the main Bro process shutting down.
|
|
||||||
*/
|
*/
|
||||||
bool FinishedRotation();
|
bool FinishedRotation();
|
||||||
|
|
||||||
|
|
|
@ -112,6 +112,9 @@ WriterFrontend::WriterFrontend(const WriterBackend::WriterInfo& arg_info, EnumVa
|
||||||
write_buffer_pos = 0;
|
write_buffer_pos = 0;
|
||||||
info = new WriterBackend::WriterInfo(arg_info);
|
info = new WriterBackend::WriterInfo(arg_info);
|
||||||
|
|
||||||
|
num_fields = 0;
|
||||||
|
fields = 0;
|
||||||
|
|
||||||
const char* w = arg_writer->Type()->AsEnumType()->Lookup(arg_writer->InternalInt());
|
const char* w = arg_writer->Type()->AsEnumType()->Lookup(arg_writer->InternalInt());
|
||||||
name = copy_string(fmt("%s/%s", arg_info.path, w));
|
name = copy_string(fmt("%s/%s", arg_info.path, w));
|
||||||
|
|
||||||
|
|
|
@ -261,7 +261,16 @@ bool Ascii::DoRotate(const char* rotated_path, double open, double close, bool t
|
||||||
CloseFile(close);
|
CloseFile(close);
|
||||||
|
|
||||||
string nname = string(rotated_path) + "." + LogExt();
|
string nname = string(rotated_path) + "." + LogExt();
|
||||||
rename(fname.c_str(), nname.c_str());
|
|
||||||
|
if ( rename(fname.c_str(), nname.c_str()) != 0 )
|
||||||
|
{
|
||||||
|
char buf[256];
|
||||||
|
strerror_r(errno, buf, sizeof(buf));
|
||||||
|
Error(Fmt("failed to rename %s to %s: %s", fname.c_str(),
|
||||||
|
nname.c_str(), buf));
|
||||||
|
FinishedRotation();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! FinishedRotation(nname.c_str(), fname.c_str(), open, close, terminating) )
|
if ( ! FinishedRotation(nname.c_str(), fname.c_str(), open, close, terminating) )
|
||||||
{
|
{
|
||||||
|
|
|
@ -233,6 +233,10 @@ DataSeries::DataSeries(WriterFrontend* frontend) : WriterBackend(frontend)
|
||||||
ds_set_separator = ",";
|
ds_set_separator = ",";
|
||||||
|
|
||||||
ascii = new AsciiFormatter(this, AsciiFormatter::SeparatorInfo());
|
ascii = new AsciiFormatter(this, AsciiFormatter::SeparatorInfo());
|
||||||
|
|
||||||
|
compress_type = Extent::compress_none;
|
||||||
|
log_file = 0;
|
||||||
|
log_output = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DataSeries::~DataSeries()
|
DataSeries::~DataSeries()
|
||||||
|
@ -423,7 +427,16 @@ bool DataSeries::DoRotate(const char* rotated_path, double open, double close, b
|
||||||
|
|
||||||
string dsname = string(Info().path) + ".ds";
|
string dsname = string(Info().path) + ".ds";
|
||||||
string nname = string(rotated_path) + ".ds";
|
string nname = string(rotated_path) + ".ds";
|
||||||
rename(dsname.c_str(), nname.c_str());
|
|
||||||
|
if ( rename(dsname.c_str(), nname.c_str()) != 0 )
|
||||||
|
{
|
||||||
|
char buf[256];
|
||||||
|
strerror_r(errno, buf, sizeof(buf));
|
||||||
|
Error(Fmt("failed to rename %s to %s: %s", dsname.c_str(),
|
||||||
|
nname.c_str(), buf));
|
||||||
|
FinishedRotation();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! FinishedRotation(nname.c_str(), dsname.c_str(), open, close, terminating) )
|
if ( ! FinishedRotation(nname.c_str(), dsname.c_str(), open, close, terminating) )
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,7 +16,9 @@ using namespace writer;
|
||||||
using threading::Value;
|
using threading::Value;
|
||||||
using threading::Field;
|
using threading::Field;
|
||||||
|
|
||||||
SQLite::SQLite(WriterFrontend* frontend) : WriterBackend(frontend)
|
SQLite::SQLite(WriterFrontend* frontend)
|
||||||
|
: WriterBackend(frontend),
|
||||||
|
fields(), num_fields(), db(), st()
|
||||||
{
|
{
|
||||||
set_separator.assign(
|
set_separator.assign(
|
||||||
(const char*) BifConst::LogSQLite::set_separator->Bytes(),
|
(const char*) BifConst::LogSQLite::set_separator->Bytes(),
|
||||||
|
@ -33,9 +35,7 @@ SQLite::SQLite(WriterFrontend* frontend) : WriterBackend(frontend)
|
||||||
BifConst::LogSQLite::empty_field->Len()
|
BifConst::LogSQLite::empty_field->Len()
|
||||||
);
|
);
|
||||||
|
|
||||||
db = 0;
|
|
||||||
io = new AsciiFormatter(this, AsciiFormatter::SeparatorInfo(set_separator, unset_field, empty_field));
|
io = new AsciiFormatter(this, AsciiFormatter::SeparatorInfo(set_separator, unset_field, empty_field));
|
||||||
st = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SQLite::~SQLite()
|
SQLite::~SQLite()
|
||||||
|
|
|
@ -782,7 +782,10 @@ int main(int argc, char** argv)
|
||||||
bro_init_magic(&magic_desc_cookie, MAGIC_NONE);
|
bro_init_magic(&magic_desc_cookie, MAGIC_NONE);
|
||||||
bro_init_magic(&magic_mime_cookie, MAGIC_MIME);
|
bro_init_magic(&magic_mime_cookie, MAGIC_MIME);
|
||||||
|
|
||||||
sqlite3_initialize();
|
int r = sqlite3_initialize();
|
||||||
|
|
||||||
|
if ( r != SQLITE_OK )
|
||||||
|
reporter->Error("Failed to initialize sqlite3: %s", sqlite3_errstr(r));
|
||||||
|
|
||||||
// FIXME: On systems that don't provide /dev/urandom, OpenSSL doesn't
|
// FIXME: On systems that don't provide /dev/urandom, OpenSSL doesn't
|
||||||
// seed the PRNG. We should do this here (but at least Linux, FreeBSD
|
// seed the PRNG. We should do this here (but at least Linux, FreeBSD
|
||||||
|
|
|
@ -81,7 +81,7 @@ private:
|
||||||
friend class ::RemoteSerializer;
|
friend class ::RemoteSerializer;
|
||||||
|
|
||||||
// Force usage of constructor above.
|
// Force usage of constructor above.
|
||||||
Field() {};
|
Field() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
19
src/util.cc
19
src/util.cc
|
@ -935,7 +935,7 @@ static const char* check_for_dir(const char* filename, bool load_pkgs)
|
||||||
return copy_string(filename);
|
return copy_string(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE* open_file(const char* filename, const char** full_filename, bool load_pkgs)
|
static FILE* open_file(const char* filename, const char** full_filename, bool load_pkgs)
|
||||||
{
|
{
|
||||||
filename = check_for_dir(filename, load_pkgs);
|
filename = check_for_dir(filename, load_pkgs);
|
||||||
|
|
||||||
|
@ -944,6 +944,13 @@ FILE* open_file(const char* filename, const char** full_filename, bool load_pkgs
|
||||||
|
|
||||||
FILE* f = fopen(filename, "r");
|
FILE* f = fopen(filename, "r");
|
||||||
|
|
||||||
|
if ( ! f )
|
||||||
|
{
|
||||||
|
char buf[256];
|
||||||
|
strerror_r(errno, buf, sizeof(buf));
|
||||||
|
reporter->Error("Failed to open file %s: %s", filename, buf);
|
||||||
|
}
|
||||||
|
|
||||||
delete [] filename;
|
delete [] filename;
|
||||||
|
|
||||||
return f;
|
return f;
|
||||||
|
@ -1261,6 +1268,16 @@ void _set_processing_status(const char* status)
|
||||||
|
|
||||||
int fd = open(proc_status_file, O_CREAT | O_WRONLY | O_TRUNC, 0700);
|
int fd = open(proc_status_file, O_CREAT | O_WRONLY | O_TRUNC, 0700);
|
||||||
|
|
||||||
|
if ( fd < 0 )
|
||||||
|
{
|
||||||
|
char buf[256];
|
||||||
|
strerror_r(errno, buf, sizeof(buf));
|
||||||
|
reporter->Error("Failed to open process status file '%s': %s",
|
||||||
|
proc_status_file, buf);
|
||||||
|
errno = old_errno;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int len = strlen(status);
|
int len = strlen(status);
|
||||||
while ( len )
|
while ( len )
|
||||||
{
|
{
|
||||||
|
|
5
testing/btest/Baseline/core.div-by-zero/out
Normal file
5
testing/btest/Baseline/core.div-by-zero/out
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
expression error in /Users/jsiwek/Projects/bro/bro/testing/btest/.tmp/core.div-by-zero/div-by-zero.bro, line 6: division by zero [a / b]
|
||||||
|
expression error in /Users/jsiwek/Projects/bro/bro/testing/btest/.tmp/core.div-by-zero/div-by-zero.bro, line 11: division by zero [a / b]
|
||||||
|
expression error in /Users/jsiwek/Projects/bro/bro/testing/btest/.tmp/core.div-by-zero/div-by-zero.bro, line 16: division by zero [a / b]
|
||||||
|
expression error in /Users/jsiwek/Projects/bro/bro/testing/btest/.tmp/core.div-by-zero/div-by-zero.bro, line 21: modulo by zero [a % b]
|
||||||
|
expression error in /Users/jsiwek/Projects/bro/bro/testing/btest/.tmp/core.div-by-zero/div-by-zero.bro, line 26: modulo by zero [a % b]
|
36
testing/btest/core/div-by-zero.bro
Normal file
36
testing/btest/core/div-by-zero.bro
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
# @TEST-EXEC: bro -b %INPUT >out 2>&1
|
||||||
|
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff out
|
||||||
|
|
||||||
|
event div_int(a: int, b: int)
|
||||||
|
{
|
||||||
|
print a / b;
|
||||||
|
}
|
||||||
|
|
||||||
|
event div_count(a: count, b: count)
|
||||||
|
{
|
||||||
|
print a / b;
|
||||||
|
}
|
||||||
|
|
||||||
|
event div_double(a: double, b: double)
|
||||||
|
{
|
||||||
|
print a / b;
|
||||||
|
}
|
||||||
|
|
||||||
|
event mod_int(a: int, b: int)
|
||||||
|
{
|
||||||
|
print a % b;
|
||||||
|
}
|
||||||
|
|
||||||
|
event mod_count(a: count, b: count)
|
||||||
|
{
|
||||||
|
print a % b;
|
||||||
|
}
|
||||||
|
|
||||||
|
event bro_init()
|
||||||
|
{
|
||||||
|
event div_int(10, 0);
|
||||||
|
event div_count(10, 0);
|
||||||
|
event div_double(10.0, 0.0);
|
||||||
|
event mod_int(10, 0);
|
||||||
|
event mod_count(10, 0);
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue