mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +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
|
||||
|
||||
* 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[1].input = special_nodes[1].output = 0xFFFFFFFF;
|
||||
|
||||
method = 0;
|
||||
before_anonymization = 1;
|
||||
new_mapping = 0;
|
||||
}
|
||||
|
||||
int AnonymizeIPAddr_A50::PreservePrefix(ipaddr32_t input, int num_bits)
|
||||
|
|
|
@ -96,7 +96,7 @@ public:
|
|||
bool operator==(const Attributes& other) const;
|
||||
|
||||
protected:
|
||||
Attributes() { type = 0; attrs = 0; }
|
||||
Attributes() : type(), attrs(), in_record() { }
|
||||
void CheckAttr(Attr* attr);
|
||||
|
||||
DECLARE_SERIAL(Attributes);
|
||||
|
|
|
@ -58,9 +58,8 @@ int pcap_compile_nopcap(int snaplen_arg, int linktype_arg,
|
|||
}
|
||||
#endif
|
||||
|
||||
BPF_Program::BPF_Program()
|
||||
BPF_Program::BPF_Program() : m_compiled(), m_program()
|
||||
{
|
||||
m_compiled = false;
|
||||
}
|
||||
|
||||
BPF_Program::~BPF_Program()
|
||||
|
|
|
@ -504,17 +504,35 @@ static void WritePluginComponents(FILE* f, const plugin::Plugin* p)
|
|||
{
|
||||
switch ( (*it)->Type() ) {
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
case plugin::component::READER:
|
||||
reporter->InternalError("docs for READER component unimplemented");
|
||||
|
||||
case plugin::component::WRITER:
|
||||
reporter->InternalError("docs for WRITER component unimplemented");
|
||||
|
||||
default:
|
||||
reporter->InternalError("docs for unknown component unimplemented");
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include <cstring>
|
||||
#include <utility>
|
||||
#include <algorithm>
|
||||
#include <sys/stat.h>
|
||||
#include "Brofiler.h"
|
||||
#include "util.h"
|
||||
|
||||
|
@ -54,7 +55,10 @@ bool Brofiler::WriteStats()
|
|||
|
||||
if ( p && ! p[7] )
|
||||
{
|
||||
mode_t old_umask = umask(S_IXUSR | S_IRWXO | S_IRWXG);
|
||||
int fd = mkstemp(bf);
|
||||
umask(old_umask);
|
||||
|
||||
if ( fd == -1 )
|
||||
{
|
||||
reporter->Error("Failed to generate unique file name from BRO_PROFILER_FILE: %s", bf);
|
||||
|
|
|
@ -14,9 +14,8 @@
|
|||
#include "NetVar.h"
|
||||
#include "RemoteSerializer.h"
|
||||
|
||||
ChunkedIO::ChunkedIO()
|
||||
ChunkedIO::ChunkedIO() : stats(), tag(), pure()
|
||||
{
|
||||
pure = false;
|
||||
}
|
||||
|
||||
void ChunkedIO::Stats(char* buffer, int length)
|
||||
|
@ -656,6 +655,7 @@ SSL_CTX* ChunkedIOSSL::ctx;
|
|||
ChunkedIOSSL::ChunkedIOSSL(int arg_socket, bool arg_server)
|
||||
{
|
||||
socket = arg_socket;
|
||||
last_ret = 0;
|
||||
eof = false;
|
||||
setup = false;
|
||||
server = arg_server;
|
||||
|
|
|
@ -292,8 +292,9 @@ private:
|
|||
// Wrapper class around a another ChunkedIO which the (un-)compresses data.
|
||||
class CompressedChunkedIO : public ChunkedIO {
|
||||
public:
|
||||
CompressedChunkedIO(ChunkedIO* arg_io)
|
||||
: io(arg_io) {} // takes ownership
|
||||
CompressedChunkedIO(ChunkedIO* arg_io) // takes ownership
|
||||
: io(arg_io), zin(), zout(), error(), compress(), uncompress(),
|
||||
uncompressed_bytes_read(), uncompressed_bytes_written() {}
|
||||
virtual ~CompressedChunkedIO() { delete io; }
|
||||
|
||||
virtual bool Init(); // does *not* call arg_io->Init()
|
||||
|
|
|
@ -11,6 +11,7 @@ CompositeHash::CompositeHash(TypeList* composite_type)
|
|||
{
|
||||
type = composite_type;
|
||||
Ref(type);
|
||||
singleton_tag = TYPE_INTERNAL_ERROR;
|
||||
|
||||
// If the only element is a record, don't treat it as a
|
||||
// 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);
|
||||
VectorVal* vv = v->AsVectorVal();
|
||||
VectorType* vt = v->Type()->AsVectorType();
|
||||
vector<Val*>* indices = v->AsVector();
|
||||
*kp = vv->Size();
|
||||
kp1 = reinterpret_cast<char*>(kp+1);
|
||||
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;
|
||||
|
||||
record_contents = record_packets = 1;
|
||||
record_current_packet = record_current_content = 0;
|
||||
|
||||
timers_canceled = 0;
|
||||
inactivity_timeout = 0;
|
||||
|
|
|
@ -20,6 +20,7 @@ DFA_State::DFA_State(int arg_state_num, const EquivClass* ec,
|
|||
nfa_states = arg_nfa_states;
|
||||
accept = arg_accept;
|
||||
mark = 0;
|
||||
centry = 0;
|
||||
|
||||
SymPartition(ec);
|
||||
|
||||
|
|
|
@ -47,8 +47,14 @@ extern int select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
|
|||
class DNS_Mgr_Request {
|
||||
public:
|
||||
DNS_Mgr_Request(const char* h, int af, bool is_txt)
|
||||
{ host = copy_string(h); fam = af; qtype = is_txt ? 16 : 0; }
|
||||
DNS_Mgr_Request(const IPAddr& a) { addr = a; host = 0; fam = 0; }
|
||||
: host(copy_string(h)), fam(af), qtype(is_txt ? 16 : 0), addr(),
|
||||
request_pending()
|
||||
{ }
|
||||
|
||||
DNS_Mgr_Request(const IPAddr& a)
|
||||
: host(), fam(), qtype(), addr(a), request_pending()
|
||||
{ }
|
||||
|
||||
~DNS_Mgr_Request() { delete [] host; }
|
||||
|
||||
// Returns nil if this was an address request.
|
||||
|
@ -192,6 +198,8 @@ DNS_Mapping::DNS_Mapping(FILE* f)
|
|||
init_failed = 1;
|
||||
|
||||
req_host = 0;
|
||||
req_ttl = 0;
|
||||
creation_time = 0;
|
||||
|
||||
char buf[512];
|
||||
|
||||
|
@ -711,17 +719,19 @@ void DNS_Mgr::AddResult(DNS_Mgr_Request* dr, struct nb_dns_result* r)
|
|||
if ( dr->ReqIsTxt() )
|
||||
{
|
||||
TextMap::iterator it = text_mappings.find(dr->ReqHost());
|
||||
|
||||
if ( it == text_mappings.end() )
|
||||
text_mappings[dr->ReqHost()] = new_dm;
|
||||
else
|
||||
{
|
||||
if ( new_dm->Failed() && prev_dm && prev_dm->Valid() )
|
||||
++keep_prev;
|
||||
else
|
||||
{
|
||||
prev_dm = it->second;
|
||||
it->second = new_dm;
|
||||
}
|
||||
|
||||
if ( new_dm->Failed() && prev_dm && prev_dm->Valid() )
|
||||
{
|
||||
text_mappings[dr->ReqHost()] = prev_dm;
|
||||
++keep_prev;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -928,7 +938,7 @@ void DNS_Mgr::Save(FILE* f, const HostMap& m)
|
|||
|
||||
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() )
|
||||
return 0;
|
||||
|
@ -937,7 +947,7 @@ const char* DNS_Mgr::LookupAddrInCache(const IPAddr& addr)
|
|||
|
||||
if ( d->Expired() )
|
||||
{
|
||||
dns_mgr->addr_mappings.erase(it);
|
||||
addr_mappings.erase(it);
|
||||
delete d;
|
||||
return 0;
|
||||
}
|
||||
|
@ -949,10 +959,10 @@ const char* DNS_Mgr::LookupAddrInCache(const IPAddr& addr)
|
|||
|
||||
TableVal* DNS_Mgr::LookupNameInCache(string name)
|
||||
{
|
||||
HostMap::iterator it = dns_mgr->host_mappings.find(name);
|
||||
if ( it == dns_mgr->host_mappings.end() )
|
||||
HostMap::iterator it = host_mappings.find(name);
|
||||
if ( it == host_mappings.end() )
|
||||
{
|
||||
it = dns_mgr->host_mappings.begin();
|
||||
it = host_mappings.begin();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -964,7 +974,7 @@ TableVal* DNS_Mgr::LookupNameInCache(string name)
|
|||
|
||||
if ( d4->Expired() || d6->Expired() )
|
||||
{
|
||||
dns_mgr->host_mappings.erase(it);
|
||||
host_mappings.erase(it);
|
||||
delete d4;
|
||||
delete d6;
|
||||
return 0;
|
||||
|
@ -979,15 +989,15 @@ TableVal* DNS_Mgr::LookupNameInCache(string name)
|
|||
|
||||
const char* DNS_Mgr::LookupTextInCache(string name)
|
||||
{
|
||||
TextMap::iterator it = dns_mgr->text_mappings.find(name);
|
||||
if ( it == dns_mgr->text_mappings.end() )
|
||||
TextMap::iterator it = text_mappings.find(name);
|
||||
if ( it == text_mappings.end() )
|
||||
return 0;
|
||||
|
||||
DNS_Mapping* d = it->second;
|
||||
|
||||
if ( d->Expired() )
|
||||
{
|
||||
dns_mgr->text_mappings.erase(it);
|
||||
text_mappings.erase(it);
|
||||
delete d;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -49,6 +49,8 @@ DbgBreakpoint::DbgBreakpoint()
|
|||
repeat_count = hit_count = 0;
|
||||
|
||||
description[0] = 0;
|
||||
source_filename = 0;
|
||||
source_line = 0;
|
||||
}
|
||||
|
||||
DbgBreakpoint::~DbgBreakpoint()
|
||||
|
@ -85,10 +87,17 @@ void DbgBreakpoint::RemoveFromGlobalMap()
|
|||
pair<BPMapType::iterator, BPMapType::iterator> p;
|
||||
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 )
|
||||
{
|
||||
BPMapType::iterator next = i;
|
||||
++next;
|
||||
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;
|
||||
BreakBeforeNextStmt(false);
|
||||
curr_frame_idx = 0;
|
||||
already_did_list = false;
|
||||
BreakFromSignal(false);
|
||||
|
||||
// ### Don't choose this arbitrary size! Extend Frame.
|
||||
|
@ -194,8 +195,7 @@ static void parse_function_name(vector<ParseLocationRec>& result,
|
|||
return;
|
||||
}
|
||||
|
||||
FuncType* ftype;
|
||||
if ( ! (ftype = id->Type()->AsFuncType()) )
|
||||
if ( ! id->Type()->AsFuncType() )
|
||||
{
|
||||
debug_msg("Function %s not declared.\n", id->Name());
|
||||
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)
|
||||
{
|
||||
ODesc d;
|
||||
const BroFunc* func = frame->GetFunction();
|
||||
const BroFunc* func = frame ? frame->GetFunction() : 0;
|
||||
|
||||
if ( func )
|
||||
func->DescribeDebug(&d, frame->GetFuncArgs());
|
||||
|
|
|
@ -64,6 +64,10 @@ Dictionary::Dictionary(dict_order ordering, int initial_size)
|
|||
SetDensityThresh(DEFAULT_DENSITY_THRESH);
|
||||
|
||||
delete_func = 0;
|
||||
tbl_next_ind = 0;
|
||||
|
||||
num_buckets2 = num_entries2 = max_num_entries2 = thresh_entries2 = 0;
|
||||
den_thresh2 = 0;
|
||||
}
|
||||
|
||||
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_REMOVE_FROM: 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_OR: DO_INT_FOLD(||); break;
|
||||
|
||||
|
@ -1090,15 +1139,10 @@ NotExpr::NotExpr(Expr* arg_op) : UnaryExpr(EXPR_NOT, arg_op)
|
|||
return;
|
||||
|
||||
BroType* t = op->Type();
|
||||
if ( IsVector(t->Tag()) )
|
||||
t = t->AsVectorType()->YieldType();
|
||||
|
||||
TypeTag bt = t->Tag();
|
||||
|
||||
if ( ! IsIntegral(bt) && bt != TYPE_BOOL )
|
||||
ExprError("requires an integral or boolean operand");
|
||||
else if ( IsVector(bt) )
|
||||
SetType(new VectorType(base_type(TYPE_BOOL)));
|
||||
else
|
||||
SetType(base_type(TYPE_BOOL));
|
||||
}
|
||||
|
@ -1112,7 +1156,7 @@ Expr* NotExpr::DoSimplify()
|
|||
// !!x == x
|
||||
return ((NotExpr*) op)->Op()->Ref();
|
||||
|
||||
if ( op->IsConst() && ! is_vector(op->ExprVal()) )
|
||||
if ( op->IsConst() )
|
||||
return new ConstExpr(Fold(op->ExprVal()));
|
||||
|
||||
return this;
|
||||
|
@ -2438,6 +2482,7 @@ AssignExpr::AssignExpr(Expr* arg_op1, Expr* arg_op2, int arg_is_init,
|
|||
: BinaryExpr(EXPR_ASSIGN,
|
||||
arg_is_init ? arg_op1 : arg_op1->MakeLvalue(), arg_op2)
|
||||
{
|
||||
val = 0;
|
||||
is_init = arg_is_init;
|
||||
|
||||
if ( IsError() )
|
||||
|
@ -3137,12 +3182,14 @@ FieldExpr::FieldExpr(Expr* arg_op, const char* arg_field_name)
|
|||
{
|
||||
RecordType* rt = op->Type()->AsRecordType();
|
||||
field = rt->FieldOffset(field_name);
|
||||
td = rt->FieldDecl(field);
|
||||
|
||||
if ( field < 0 )
|
||||
ExprError("no such field in record");
|
||||
else
|
||||
{
|
||||
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);
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
bool HasFieldExpr::DoUnserialize(UnserialInfo* info)
|
||||
{
|
||||
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;
|
||||
return UNSERIALIZE(¬_used) && UNSERIALIZE_STR(&field_name, 0) && UNSERIALIZE(&field);
|
||||
}
|
||||
|
@ -3325,6 +3372,8 @@ RecordConstructorExpr::RecordConstructorExpr(ListExpr* constructor_list,
|
|||
BroType* arg_type)
|
||||
: UnaryExpr(EXPR_RECORD_CONSTRUCTOR, constructor_list)
|
||||
{
|
||||
ctor_type = 0;
|
||||
|
||||
if ( IsError() )
|
||||
return;
|
||||
|
||||
|
@ -3465,6 +3514,8 @@ TableConstructorExpr::TableConstructorExpr(ListExpr* constructor_list,
|
|||
attr_list* arg_attrs, BroType* arg_type)
|
||||
: UnaryExpr(EXPR_TABLE_CONSTRUCTOR, constructor_list)
|
||||
{
|
||||
attrs = 0;
|
||||
|
||||
if ( IsError() )
|
||||
return;
|
||||
|
||||
|
@ -3589,6 +3640,8 @@ SetConstructorExpr::SetConstructorExpr(ListExpr* constructor_list,
|
|||
attr_list* arg_attrs, BroType* arg_type)
|
||||
: UnaryExpr(EXPR_SET_CONSTRUCTOR, constructor_list)
|
||||
{
|
||||
attrs = 0;
|
||||
|
||||
if ( IsError() )
|
||||
return;
|
||||
|
||||
|
@ -3852,7 +3905,15 @@ void FieldAssignExpr::EvalIntoAggregate(const BroType* t, Val* aggr, Frame* f)
|
|||
Val* v = op->Eval(f);
|
||||
|
||||
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
|
||||
|
@ -5386,7 +5447,7 @@ TraversalCode ListExpr::Traverse(TraversalCallback* cb) const
|
|||
|
||||
loop_over_list(exprs, i)
|
||||
{
|
||||
exprs[i]->Traverse(cb);
|
||||
tc = exprs[i]->Traverse(cb);
|
||||
HANDLE_TC_EXPR_PRE(tc);
|
||||
}
|
||||
|
||||
|
|
|
@ -331,12 +331,10 @@ protected:
|
|||
BinaryExpr() { op1 = op2 = 0; }
|
||||
|
||||
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) )
|
||||
return;
|
||||
op1 = arg_op1;
|
||||
op2 = arg_op2;
|
||||
if ( op1->IsError() || op2->IsError() )
|
||||
SetError();
|
||||
}
|
||||
|
@ -749,7 +747,6 @@ protected:
|
|||
|
||||
DECLARE_SERIAL(HasFieldExpr);
|
||||
|
||||
bool is_attr;
|
||||
const char* field_name;
|
||||
int field;
|
||||
};
|
||||
|
|
|
@ -147,7 +147,6 @@ protected:
|
|||
|
||||
Timer* rotate_timer;
|
||||
double open_time;
|
||||
bool dont_rotate; // See InstallRotateTimer()
|
||||
bool print_hook;
|
||||
bool raw_output;
|
||||
|
||||
|
|
|
@ -64,7 +64,6 @@ void FlowSrc::Close()
|
|||
|
||||
FlowSocketSrc::~FlowSocketSrc()
|
||||
{
|
||||
delete [] listenparms;
|
||||
}
|
||||
|
||||
int FlowSocketSrc::ExtractNextPDU()
|
||||
|
|
|
@ -67,9 +67,6 @@ public:
|
|||
virtual ~FlowSocketSrc();
|
||||
|
||||
int ExtractNextPDU();
|
||||
|
||||
protected:
|
||||
char* listenparms;
|
||||
};
|
||||
|
||||
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);
|
||||
info->s->WriteOpenTag("Location");
|
||||
SERIALIZE(filename);
|
||||
SERIALIZE(first_line);
|
||||
SERIALIZE(last_line);
|
||||
SERIALIZE(first_column);
|
||||
SERIALIZE(last_column);
|
||||
|
||||
if ( ! (SERIALIZE(filename) &&
|
||||
SERIALIZE(first_line) &&
|
||||
SERIALIZE(last_line) &&
|
||||
SERIALIZE(first_column) &&
|
||||
SERIALIZE(last_column)) )
|
||||
return false;
|
||||
|
||||
info->s->WriteCloseTag("Location");
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -400,8 +400,6 @@ bool PersistenceSerializer::RunSerialization(SerialStatus* status)
|
|||
|
||||
while ( (id = status->ids->NextEntry(status->id_cookie)) )
|
||||
{
|
||||
ID* g = global_scope()->Lookup(id->Name());
|
||||
|
||||
if ( ! DoIDSerialization(status, id) )
|
||||
return false;
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <map>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
@ -80,7 +81,13 @@ bool LoadPolicyFileText(const char* policy_filename)
|
|||
policy_files.insert(PolicyFileMap::value_type(policy_filename, pf));
|
||||
|
||||
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;
|
||||
off_t size = st.st_size;
|
||||
|
|
|
@ -541,6 +541,10 @@ RemoteSerializer::RemoteSerializer()
|
|||
in_sync = 0;
|
||||
last_flush = 0;
|
||||
received_logs = 0;
|
||||
current_id = 0;
|
||||
current_msgtype = 0;
|
||||
current_args = 0;
|
||||
source_peer = 0;
|
||||
}
|
||||
|
||||
RemoteSerializer::~RemoteSerializer()
|
||||
|
@ -1247,7 +1251,7 @@ bool RemoteSerializer::SendCapabilities(Peer* peer)
|
|||
caps |= Peer::PID_64BIT;
|
||||
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,
|
||||
|
|
|
@ -28,6 +28,7 @@ public:
|
|||
idx = rule_counter++;
|
||||
location = arg_location;
|
||||
active = true;
|
||||
next = 0;
|
||||
}
|
||||
|
||||
~Rule();
|
||||
|
|
|
@ -103,7 +103,7 @@ private:
|
|||
friend class RuleMatcher;
|
||||
|
||||
struct PatternSet {
|
||||
PatternSet() {}
|
||||
PatternSet() : re() {}
|
||||
|
||||
// If we're above the 'RE_level' (see RuleMatcher), this
|
||||
// expr contains all patterns on this node. If we're on
|
||||
|
|
|
@ -20,6 +20,7 @@ public:
|
|||
|
||||
SerialInfo(const SerialInfo& info)
|
||||
{
|
||||
chunk = info.chunk;
|
||||
s = info.s;
|
||||
may_suspend = info.may_suspend;
|
||||
cache = info.cache;
|
||||
|
|
|
@ -319,7 +319,8 @@ public:
|
|||
\
|
||||
if ( has_it ) \
|
||||
{ \
|
||||
info->s->Read(&dst, 0, "has_" #dst); \
|
||||
if ( ! info->s->Read(&dst, 0, "has_" #dst) ) \
|
||||
return false; \
|
||||
if ( ! dst ) \
|
||||
return false; \
|
||||
} \
|
||||
|
@ -339,7 +340,11 @@ public:
|
|||
\
|
||||
if ( has_it ) \
|
||||
{ \
|
||||
info->s->Read(&dst, 0, "has_" #dst); \
|
||||
if ( ! info->s->Read(&dst, 0, "has_" #dst) ) \
|
||||
{ \
|
||||
delete del; \
|
||||
return 0; \
|
||||
} \
|
||||
if ( ! dst ) \
|
||||
{ \
|
||||
delete del; \
|
||||
|
|
|
@ -6,8 +6,9 @@
|
|||
#include "Reporter.h"
|
||||
|
||||
SerializationFormat::SerializationFormat()
|
||||
: output(), output_size(), output_pos(), input(), input_len(), input_pos(),
|
||||
bytes_written(), bytes_read()
|
||||
{
|
||||
output = 0;
|
||||
}
|
||||
|
||||
SerializationFormat::~SerializationFormat()
|
||||
|
|
|
@ -136,7 +136,14 @@ bool Serializer::Serialize(SerialInfo* info, const char* func, val_list* args)
|
|||
Write(network_time, "time");
|
||||
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");
|
||||
WriteSeparator();
|
||||
|
@ -1032,6 +1039,7 @@ void ConversionSerializer::GotPacket(Packet* p)
|
|||
}
|
||||
|
||||
EventPlayer::EventPlayer(const char* file)
|
||||
: stream_time(), replay_time(), ne_time(), ne_handler(), ne_args()
|
||||
{
|
||||
if ( ! OpenFile(file, true) || fd < 0 )
|
||||
Error(fmt("event replayer: cannot open %s", file));
|
||||
|
|
|
@ -403,6 +403,7 @@ public:
|
|||
hdr_size = 0;
|
||||
free = arg_free;
|
||||
tag = arg_tag;
|
||||
link_type = 0;
|
||||
}
|
||||
|
||||
~Packet()
|
||||
|
|
|
@ -55,15 +55,12 @@ struct SessionStats {
|
|||
class TimerMgrExpireTimer : public Timer {
|
||||
public:
|
||||
TimerMgrExpireTimer(double t, TimerMgr* arg_mgr)
|
||||
: Timer(t, TIMER_TIMERMGR_EXPIRE)
|
||||
{
|
||||
mgr = arg_mgr;
|
||||
}
|
||||
: Timer(t, TIMER_TIMERMGR_EXPIRE), mgr(arg_mgr)
|
||||
{ }
|
||||
|
||||
virtual void Dispatch(double t, int is_expire);
|
||||
|
||||
protected:
|
||||
double interval;
|
||||
TimerMgr* mgr;
|
||||
};
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include "Reporter.h"
|
||||
|
||||
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 )
|
||||
_aligns.push_back(*it);
|
||||
|
|
|
@ -42,10 +42,10 @@ public:
|
|||
typedef BSSAlignVec::const_iterator BSSAlignVecCIt;
|
||||
|
||||
BroSubstring(const string& string)
|
||||
: BroString(string), _new(false) { }
|
||||
: BroString(string), _num(), _new(false) { }
|
||||
|
||||
BroSubstring(const BroString& string)
|
||||
: BroString(string), _new(false) { }
|
||||
: BroString(string), _num(), _new(false) { }
|
||||
|
||||
BroSubstring(const BroSubstring& bst);
|
||||
|
||||
|
|
|
@ -399,6 +399,7 @@ PacketProfiler::PacketProfiler(unsigned int mode, double freq,
|
|||
last_Utime = last_Stime = last_Rtime = 0.0;
|
||||
last_timestamp = time = 0.0;
|
||||
pkt_cnt = byte_cnt = 0;
|
||||
last_mem = 0;
|
||||
|
||||
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.
|
||||
SegmentProfiler(SegmentStatsReporter* arg_reporter,
|
||||
const char* arg_name)
|
||||
: reporter(arg_reporter), name(arg_name), loc(), initial_rusage()
|
||||
{
|
||||
reporter = arg_reporter;
|
||||
if ( reporter )
|
||||
{
|
||||
name = arg_name;
|
||||
loc = 0;
|
||||
Init();
|
||||
}
|
||||
}
|
||||
|
||||
SegmentProfiler(SegmentStatsReporter* arg_reporter,
|
||||
const Location* arg_loc)
|
||||
: reporter(arg_reporter), name(), loc(arg_loc), initial_rusage()
|
||||
{
|
||||
reporter = arg_reporter;
|
||||
if ( reporter )
|
||||
{
|
||||
name = 0;
|
||||
loc = arg_loc;
|
||||
Init();
|
||||
}
|
||||
}
|
||||
|
||||
~SegmentProfiler()
|
||||
{
|
||||
|
|
|
@ -1218,9 +1218,8 @@ Val* ForStmt::DoExec(Frame* f, Val* v, stmt_flow_type& flow) const
|
|||
const PDict(TableEntryVal)* loop_vals = tv->AsTable();
|
||||
|
||||
HashKey* k;
|
||||
TableEntryVal* iter_val;
|
||||
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);
|
||||
delete k;
|
||||
|
|
|
@ -179,7 +179,8 @@ unsigned int BroType::MemoryAllocation() const
|
|||
bool BroType::Serialize(SerialInfo* info) const
|
||||
{
|
||||
// We always send full types (see below).
|
||||
SERIALIZE(true);
|
||||
if ( ! SERIALIZE(true) )
|
||||
return false;
|
||||
|
||||
bool ret = SerialObj::Serialize(info);
|
||||
return ret;
|
||||
|
@ -1563,10 +1564,8 @@ bool EnumType::DoUnserialize(UnserialInfo* info)
|
|||
}
|
||||
|
||||
VectorType::VectorType(BroType* element_type)
|
||||
: BroType(TYPE_VECTOR)
|
||||
: BroType(TYPE_VECTOR), yield_type(element_type)
|
||||
{
|
||||
if ( element_type )
|
||||
yield_type = element_type;
|
||||
}
|
||||
|
||||
VectorType::~VectorType()
|
||||
|
|
38
src/Val.cc
38
src/Val.cc
|
@ -81,7 +81,9 @@ Val* Val::Clone() const
|
|||
SerialInfo sinfo(&ss);
|
||||
sinfo.cache = false;
|
||||
|
||||
this->Serialize(&sinfo);
|
||||
if ( ! this->Serialize(&sinfo) )
|
||||
return 0;
|
||||
|
||||
char* data;
|
||||
uint32 len = form->EndWrite(&data);
|
||||
form->StartRead(data, len);
|
||||
|
@ -1656,8 +1658,7 @@ int TableVal::RemoveFrom(Val* val) const
|
|||
IterCookie* c = tbl->InitForIteration();
|
||||
|
||||
HashKey* k;
|
||||
TableEntryVal* v;
|
||||
while ( (v = tbl->NextEntry(k, c)) )
|
||||
while ( tbl->NextEntry(k, c) )
|
||||
{
|
||||
Val* index = RecoverIndex(k);
|
||||
|
||||
|
@ -1955,8 +1956,7 @@ ListVal* TableVal::ConvertToList(TypeTag t) const
|
|||
IterCookie* c = tbl->InitForIteration();
|
||||
|
||||
HashKey* k;
|
||||
TableEntryVal* v;
|
||||
while ( (v = tbl->NextEntry(k, c)) )
|
||||
while ( tbl->NextEntry(k, c) )
|
||||
{
|
||||
ListVal* index = table_hash->RecoverVals(k);
|
||||
|
||||
|
@ -2162,7 +2162,7 @@ void TableVal::DoExpire(double t)
|
|||
|
||||
else if ( v->ExpireAccessTime() + expire_time < t )
|
||||
{
|
||||
Val* val = v ? v->Value() : 0;
|
||||
Val* val = v->Value();
|
||||
|
||||
if ( expire_expr )
|
||||
{
|
||||
|
@ -2328,7 +2328,7 @@ bool TableVal::DoSerialize(SerialInfo* info) const
|
|||
else
|
||||
reporter->InternalError("unknown continuation state");
|
||||
|
||||
HashKey* k;
|
||||
HashKey* k = 0;
|
||||
int count = 0;
|
||||
|
||||
assert((!info->cont.ChildSuspended()) || state->v);
|
||||
|
@ -2341,12 +2341,21 @@ bool TableVal::DoSerialize(SerialInfo* info) const
|
|||
if ( ! state->c )
|
||||
{
|
||||
// No next one.
|
||||
SERIALIZE(false);
|
||||
if ( ! SERIALIZE(false) )
|
||||
{
|
||||
delete k;
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// There's a value coming.
|
||||
SERIALIZE(true);
|
||||
if ( ! SERIALIZE(true) )
|
||||
{
|
||||
delete k;
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( state->v->Value() )
|
||||
state->v->Ref();
|
||||
|
@ -2563,6 +2572,7 @@ unsigned int TableVal::MemoryAllocation() const
|
|||
|
||||
RecordVal::RecordVal(RecordType* t) : MutableVal(t)
|
||||
{
|
||||
origin = 0;
|
||||
record_type = t;
|
||||
int n = record_type->NumFields();
|
||||
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);
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
if ( ! record_promotion_compatible(t->AsRecordType(), Type()->AsRecordType()) )
|
||||
|
|
13
src/Val.h
13
src/Val.h
|
@ -466,7 +466,7 @@ public:
|
|||
protected:
|
||||
MutableVal(BroType* t) : Val(t)
|
||||
{ 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();
|
||||
|
||||
friend class ID;
|
||||
|
@ -895,6 +895,17 @@ public:
|
|||
Val* Lookup(int field) const; // Does not 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;
|
||||
|
||||
// This is an experiment to associate a BroObj within the
|
||||
|
|
|
@ -20,7 +20,7 @@ public:
|
|||
void Dispatch(double t, int is_expire);
|
||||
|
||||
protected:
|
||||
AnalyzerTimer() {}
|
||||
AnalyzerTimer() : analyzer(), timer(), 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;
|
||||
id = ++id_counter;
|
||||
protocol_confirmed = false;
|
||||
timers_canceled = false;
|
||||
skip = false;
|
||||
finished = false;
|
||||
removing = false;
|
||||
|
|
|
@ -79,7 +79,7 @@ flow AYIYA_Flow
|
|||
|
||||
sessions->DoNextInnerPacket(network_time(), 0, inner, e, ec);
|
||||
|
||||
return (result == 0) ? true : false;
|
||||
return true;
|
||||
%}
|
||||
|
||||
};
|
||||
|
|
|
@ -11,7 +11,8 @@
|
|||
using namespace analyzer::conn_size;
|
||||
|
||||
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)
|
||||
{
|
||||
// RecordType *connection_type is decleared in NetVar.h
|
||||
int orig_endp_idx = connection_type->FieldOffset("orig");
|
||||
int resp_endp_idx = connection_type->FieldOffset("resp");
|
||||
RecordVal *orig_endp = conn_val->Lookup(orig_endp_idx)->AsRecordVal();
|
||||
RecordVal *resp_endp = conn_val->Lookup(resp_endp_idx)->AsRecordVal();
|
||||
RecordVal *orig_endp = conn_val->Lookup("orig")->AsRecordVal();
|
||||
RecordVal *resp_endp = conn_val->Lookup("resp")->AsRecordVal();
|
||||
|
||||
// endpoint is the RecordType from NetVar.h
|
||||
// TODO: or orig_endp->Type()->AsRecordVal()->FieldOffset()
|
||||
int pktidx = endpoint->FieldOffset("num_pkts");
|
||||
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(bytesidx, new Val(orig_bytes, 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;
|
||||
skip_event = 0;
|
||||
tsig = 0;
|
||||
}
|
||||
|
||||
DNS_MsgInfo::~DNS_MsgInfo()
|
||||
|
@ -1002,7 +1003,7 @@ Contents_DNS::Contents_DNS(Connection* conn, bool orig,
|
|||
interp = arg_interp;
|
||||
|
||||
msg_buf = 0;
|
||||
buf_n = msg_size = 0;
|
||||
buf_n = buf_len = msg_size = 0;
|
||||
state = DNS_LEN_HI;
|
||||
}
|
||||
|
||||
|
|
|
@ -144,7 +144,6 @@ public:
|
|||
// More values for spesific DNS types.
|
||||
// struct EDNS_ADDITIONAL* edns;
|
||||
|
||||
int tsig_init;
|
||||
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);
|
||||
BeginEntity(top_level);
|
||||
|
||||
buffer_offset = buffer_size = 0;
|
||||
data_buffer = 0;
|
||||
total_buffer_size = 0;
|
||||
|
||||
|
|
|
@ -17,11 +17,10 @@
|
|||
using namespace analyzer::icmp;
|
||||
|
||||
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);
|
||||
request_len = reply_len = -1;
|
||||
}
|
||||
|
||||
void ICMP_Analyzer::Done()
|
||||
|
@ -440,10 +439,8 @@ void ICMP_Analyzer::Describe(ODesc* d) const
|
|||
|
||||
void ICMP_Analyzer::UpdateConnVal(RecordVal *conn_val)
|
||||
{
|
||||
int orig_endp_idx = connection_type->FieldOffset("orig");
|
||||
int resp_endp_idx = connection_type->FieldOffset("resp");
|
||||
RecordVal *orig_endp = conn_val->Lookup(orig_endp_idx)->AsRecordVal();
|
||||
RecordVal *resp_endp = conn_val->Lookup(resp_endp_idx)->AsRecordVal();
|
||||
RecordVal *orig_endp = conn_val->Lookup("orig")->AsRecordVal();
|
||||
RecordVal *resp_endp = conn_val->Lookup("resp")->AsRecordVal();
|
||||
|
||||
UpdateEndpointVal(orig_endp, 1);
|
||||
UpdateEndpointVal(resp_endp, 0);
|
||||
|
|
|
@ -25,7 +25,7 @@ static RE_Matcher* re_login_timeouts;
|
|||
static RE_Matcher* init_RE(ListVal* l);
|
||||
|
||||
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;
|
||||
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)
|
||||
: 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()
|
||||
|
|
|
@ -22,7 +22,10 @@ Contents_Rsh_Analyzer::Contents_Rsh_Analyzer(Connection* conn, bool orig,
|
|||
if ( orig )
|
||||
state = save_state = RSH_FIRST_NULL;
|
||||
else
|
||||
{
|
||||
state = RSH_LINE_MODE;
|
||||
save_state = RSH_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
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_Message(mail_analyzer)
|
||||
: MIME_Message(mail_analyzer), md5_hash()
|
||||
{
|
||||
analyzer = mail_analyzer;
|
||||
|
||||
|
@ -1280,12 +1280,13 @@ MIME_Mail::MIME_Mail(analyzer::Analyzer* mail_analyzer, int buf_size)
|
|||
if ( mime_content_hash )
|
||||
{
|
||||
compute_content_hash = 1;
|
||||
content_hash_length = 0;
|
||||
md5_init(&md5_hash);
|
||||
}
|
||||
else
|
||||
compute_content_hash = 0;
|
||||
|
||||
content_hash_length = 0;
|
||||
|
||||
top_level = new MIME_Entity(this, 0); // to be changed to MIME_Mail
|
||||
BeginEntity(top_level);
|
||||
}
|
||||
|
|
|
@ -247,7 +247,6 @@ protected:
|
|||
int max_chunk_length;
|
||||
int buffer_start;
|
||||
int data_start;
|
||||
int buffer_offset;
|
||||
int compute_content_hash;
|
||||
int content_hash_length;
|
||||
MD5_CTX md5_hash;
|
||||
|
|
|
@ -346,7 +346,7 @@ Contents_NetbiosSSN::Contents_NetbiosSSN(Connection* conn, bool orig,
|
|||
interp = arg_interp;
|
||||
type = flags = msg_size = 0;
|
||||
msg_buf = 0;
|
||||
buf_n = msg_size = 0;
|
||||
buf_n = buf_len = msg_size = 0;
|
||||
state = NETBIOS_SSN_TYPE;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,9 +7,8 @@
|
|||
using namespace analyzer::pia;
|
||||
|
||||
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()
|
||||
|
|
|
@ -43,6 +43,9 @@ POP3_Analyzer::POP3_Analyzer(Connection* conn)
|
|||
multiLine = false;
|
||||
backOff = false;
|
||||
|
||||
lastRequiredCommand = 0;
|
||||
authLines = 0;
|
||||
|
||||
mail = 0;
|
||||
|
||||
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_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 )
|
||||
ADD_ANALYZER_TIMER(&RPC_Analyzer::ExpireTimer,
|
||||
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)
|
||||
{
|
||||
analyzer = arg_analyzer;
|
||||
req_cmd = 0;
|
||||
smb_mailslot_prot = false;
|
||||
smb_pipe_prot = false;
|
||||
dce_rpc_session = 0;
|
||||
init_SMB_command_name();
|
||||
|
||||
|
|
|
@ -1102,11 +1102,8 @@ void TCP_Analyzer::FlipRoles()
|
|||
|
||||
void TCP_Analyzer::UpdateConnVal(RecordVal *conn_val)
|
||||
{
|
||||
int orig_endp_idx = connection_type->FieldOffset("orig");
|
||||
int resp_endp_idx = connection_type->FieldOffset("resp");
|
||||
|
||||
RecordVal *orig_endp_val = conn_val->Lookup(orig_endp_idx)->AsRecordVal();
|
||||
RecordVal *resp_endp_val = conn_val->Lookup(resp_endp_idx)->AsRecordVal();
|
||||
RecordVal *orig_endp_val = conn_val->Lookup("orig")->AsRecordVal();
|
||||
RecordVal *resp_endp_val = conn_val->Lookup("resp")->AsRecordVal();
|
||||
|
||||
orig_endp_val->Assign(0, new Val(orig->Size(), 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)
|
||||
: 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_seq = window_ack_seq = 0;
|
||||
contents_start_seq = 0;
|
||||
FIN_seq = 0;
|
||||
SYN_cnt = FIN_cnt = RST_cnt = 0;
|
||||
did_close = 0;
|
||||
contents_file = 0;
|
||||
tcp_analyzer = arg_analyzer;
|
||||
is_orig = arg_is_orig;
|
||||
|
||||
hist_last_SYN = hist_last_FIN = hist_last_RST = 0;
|
||||
|
||||
src_addr = is_orig ? tcp_analyzer->Conn()->RespAddr() :
|
||||
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)
|
||||
{
|
||||
int orig_endp_idx = connection_type->FieldOffset("orig");
|
||||
int resp_endp_idx = connection_type->FieldOffset("resp");
|
||||
RecordVal *orig_endp = conn_val->Lookup(orig_endp_idx)->AsRecordVal();
|
||||
RecordVal *resp_endp = conn_val->Lookup(resp_endp_idx)->AsRecordVal();
|
||||
RecordVal *orig_endp = conn_val->Lookup("orig")->AsRecordVal();
|
||||
RecordVal *resp_endp = conn_val->Lookup("resp")->AsRecordVal();
|
||||
|
||||
orig_endp = conn_val->Lookup(orig_endp_idx)->AsRecordVal();
|
||||
resp_endp = conn_val->Lookup(resp_endp_idx)->AsRecordVal();
|
||||
UpdateEndpointVal(orig_endp, 1);
|
||||
UpdateEndpointVal(resp_endp, 0);
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ BuiltinFuncArg::BuiltinFuncArg(const char* arg_name, int arg_type)
|
|||
name = arg_name;
|
||||
type = arg_type;
|
||||
type_str = "";
|
||||
attr_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)
|
||||
{
|
||||
using BifType::Record::Files::AnalyzerArgs;
|
||||
|
||||
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);
|
||||
Val* chunk_val = args->Lookup("chunk_event");
|
||||
Val* stream_val = args->Lookup("stream_event");
|
||||
|
||||
if ( ! chunk_val && ! stream_val ) return 0;
|
||||
|
||||
|
|
|
@ -33,8 +33,7 @@ Extract::~Extract()
|
|||
|
||||
static Val* get_extract_field_val(RecordVal* args, const char* name)
|
||||
{
|
||||
using BifType::Record::Files::AnalyzerArgs;
|
||||
Val* rval = args->Lookup(AnalyzerArgs->FieldOffset(name));
|
||||
Val* rval = args->Lookup(name);
|
||||
|
||||
if ( ! rval )
|
||||
reporter->Error("File extraction analyzer missing arg field: %s", name);
|
||||
|
|
|
@ -30,7 +30,6 @@ private:
|
|||
binpac::Unified2::Unified2_Analyzer* interp;
|
||||
|
||||
string filename;
|
||||
int fd;
|
||||
};
|
||||
|
||||
} // namespace file_analysis
|
||||
|
|
|
@ -84,16 +84,16 @@ public:
|
|||
|
||||
RecordVal* description;
|
||||
|
||||
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()
|
||||
|
@ -154,24 +154,17 @@ public:
|
|||
~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()
|
||||
|
@ -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()
|
||||
|
@ -296,7 +289,7 @@ bool Manager::CreateStream(Stream* info, RecordVal* description)
|
|||
return false;
|
||||
}
|
||||
|
||||
Val* name_val = description->LookupWithDefault(rtype->FieldOffset("name"));
|
||||
Val* name_val = description->Lookup("name", true);
|
||||
string name = name_val->AsString()->CheckString();
|
||||
Unref(name_val);
|
||||
|
||||
|
@ -308,10 +301,10 @@ bool Manager::CreateStream(Stream* info, RecordVal* description)
|
|||
return false;
|
||||
}
|
||||
|
||||
EnumVal* reader = description->LookupWithDefault(rtype->FieldOffset("reader"))->AsEnumVal();
|
||||
EnumVal* reader = description->Lookup("reader", true)->AsEnumVal();
|
||||
|
||||
// get the source ...
|
||||
Val* sourceval = description->LookupWithDefault(rtype->FieldOffset("source"));
|
||||
Val* sourceval = description->Lookup("source", true);
|
||||
assert ( sourceval != 0 );
|
||||
const BroString* bsource = sourceval->AsString();
|
||||
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.name = copy_string(name.c_str());
|
||||
|
||||
EnumVal* mode = description->LookupWithDefault(rtype->FieldOffset("mode"))->AsEnumVal();
|
||||
EnumVal* mode = description->Lookup("mode", true)->AsEnumVal();
|
||||
switch ( mode->InternalInt() )
|
||||
{
|
||||
case 0:
|
||||
|
@ -342,7 +335,7 @@ bool Manager::CreateStream(Stream* info, RecordVal* description)
|
|||
|
||||
Unref(mode);
|
||||
|
||||
Val* config = description->LookupWithDefault(rtype->FieldOffset("config"));
|
||||
Val* config = description->Lookup("config", true);
|
||||
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();
|
||||
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;
|
||||
|
||||
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.
|
||||
}
|
||||
|
||||
TableVal *dst = fval->LookupWithDefault(rtype->FieldOffset("destination"))->AsTableVal();
|
||||
TableVal *dst = fval->Lookup("destination", true)->AsTableVal();
|
||||
|
||||
// check if index fields match table description
|
||||
int num = idx->NumFields();
|
||||
|
@ -588,9 +581,9 @@ bool Manager::CreateTableStream(RecordVal* fval)
|
|||
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;
|
||||
Unref(event_val);
|
||||
|
||||
|
@ -1153,7 +1146,6 @@ int Manager::SendEntryTable(Stream* i, const Value* const *vals)
|
|||
{
|
||||
// just quit and delete everything we created.
|
||||
delete idxhash;
|
||||
delete h;
|
||||
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.
|
||||
frontend = arg_frontend;
|
||||
info = new ReaderInfo(frontend->Info());
|
||||
num_fields = 0;
|
||||
fields = 0;
|
||||
|
||||
SetName(frontend->Name());
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ using threading::Value;
|
|||
using threading::Field;
|
||||
|
||||
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;
|
||||
secondary_position = -1;
|
||||
|
@ -49,6 +49,7 @@ FieldMapping FieldMapping::subType()
|
|||
Ascii::Ascii(ReaderFrontend *frontend) : ReaderBackend(frontend)
|
||||
{
|
||||
file = 0;
|
||||
mtime = 0;
|
||||
|
||||
separator.assign( (const char*) BifConst::InputAscii::separator->Bytes(),
|
||||
BifConst::InputAscii::separator->Len());
|
||||
|
|
|
@ -18,6 +18,7 @@ using threading::Field;
|
|||
|
||||
Benchmark::Benchmark(ReaderFrontend *frontend) : ReaderBackend(frontend)
|
||||
{
|
||||
num_lines = 0;
|
||||
multiplication_factor = double(BifConst::InputBenchmark::factor);
|
||||
autospread = double(BifConst::InputBenchmark::autospread);
|
||||
spread = int(BifConst::InputBenchmark::spread);
|
||||
|
@ -25,6 +26,7 @@ Benchmark::Benchmark(ReaderFrontend *frontend) : ReaderBackend(frontend)
|
|||
autospread_time = 0;
|
||||
stopspreadat = int(BifConst::InputBenchmark::stopspreadat);
|
||||
timedspread = double(BifConst::InputBenchmark::timedspread);
|
||||
heartbeatstarttime = 0;
|
||||
heartbeat_interval = double(BifConst::Threading::heartbeat_interval);
|
||||
|
||||
ascii = new AsciiFormatter(this, AsciiFormatter::SeparatorInfo());
|
||||
|
|
|
@ -34,6 +34,9 @@ Raw::Raw(ReaderFrontend *frontend) : ReaderBackend(frontend)
|
|||
{
|
||||
file = 0;
|
||||
stderrfile = 0;
|
||||
execute = false;
|
||||
firstrun = true;
|
||||
mtime = 0;
|
||||
forcekill = false;
|
||||
separator.assign( (const char*) BifConst::InputRaw::record_separator->Bytes(),
|
||||
BifConst::InputRaw::record_separator->Len());
|
||||
|
@ -95,6 +98,18 @@ void Raw::ClosePipeEnd(int i)
|
|||
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()
|
||||
{
|
||||
int res = pthread_mutex_lock(&fork_mutex);
|
||||
|
@ -200,11 +215,15 @@ bool Raw::Execute()
|
|||
ClosePipeEnd(stdout_out);
|
||||
|
||||
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);
|
||||
|
||||
if ( stdin_towrite )
|
||||
{
|
||||
// Ya, just always set this to nonblocking. we do not
|
||||
// want to block on a program receiving data. Note
|
||||
// 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
|
||||
// everything, the rest will be stuck in a queue that
|
||||
// is never emptied.
|
||||
fcntl(pipes[stdin_out], F_SETFL, O_NONBLOCK);
|
||||
if ( ! SetFDFlags(pipes[stdin_out], F_SETFL, O_NONBLOCK) )
|
||||
return false;
|
||||
}
|
||||
else
|
||||
ClosePipeEnd(stdin_out);
|
||||
|
||||
ClosePipeEnd(stderr_out);
|
||||
|
||||
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
|
||||
ClosePipeEnd(stderr_in);
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ protected:
|
|||
|
||||
private:
|
||||
void ClosePipeEnd(int i);
|
||||
bool SetFDFlags(int fd, int cmd, int flags);
|
||||
bool LockForkMutex();
|
||||
bool UnlockForkMutex();
|
||||
|
||||
|
|
|
@ -17,7 +17,9 @@ using namespace input::reader;
|
|||
using threading::Value;
|
||||
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(
|
||||
(const char*) BifConst::LogSQLite::set_separator->Bytes(),
|
||||
|
|
|
@ -295,7 +295,7 @@ bool Manager::CreateStream(EnumVal* id, RecordVal* sval)
|
|||
return false;
|
||||
}
|
||||
|
||||
RecordType* columns = sval->Lookup(rtype->FieldOffset("columns"))
|
||||
RecordType* columns = sval->Lookup("columns")
|
||||
->AsType()->AsTypeType()->Type()->AsRecordType();
|
||||
|
||||
bool log_attr_present = false;
|
||||
|
@ -322,7 +322,7 @@ bool Manager::CreateStream(EnumVal* id, RecordVal* sval)
|
|||
return false;
|
||||
}
|
||||
|
||||
Val* event_val = sval->Lookup(rtype->FieldOffset("ev"));
|
||||
Val* event_val = sval->Lookup("ev");
|
||||
Func* event = event_val ? event_val->AsFunc() : 0;
|
||||
|
||||
if ( event )
|
||||
|
@ -579,19 +579,18 @@ bool Manager::AddFilter(EnumVal* id, RecordVal* fval)
|
|||
return false;
|
||||
|
||||
// Find the right writer type.
|
||||
int idx = rtype->FieldOffset("writer");
|
||||
EnumVal* writer = fval->LookupWithDefault(idx)->AsEnumVal();
|
||||
EnumVal* writer = fval->Lookup("writer", true)->AsEnumVal();
|
||||
|
||||
// Create a new Filter instance.
|
||||
|
||||
Val* name = fval->LookupWithDefault(rtype->FieldOffset("name"));
|
||||
Val* pred = fval->LookupWithDefault(rtype->FieldOffset("pred"));
|
||||
Val* path_func = fval->LookupWithDefault(rtype->FieldOffset("path_func"));
|
||||
Val* log_local = fval->LookupWithDefault(rtype->FieldOffset("log_local"));
|
||||
Val* log_remote = fval->LookupWithDefault(rtype->FieldOffset("log_remote"));
|
||||
Val* interv = fval->LookupWithDefault(rtype->FieldOffset("interv"));
|
||||
Val* postprocessor = fval->LookupWithDefault(rtype->FieldOffset("postprocessor"));
|
||||
Val* config = fval->LookupWithDefault(rtype->FieldOffset("config"));
|
||||
Val* name = fval->Lookup("name", true);
|
||||
Val* pred = fval->Lookup("pred", true);
|
||||
Val* path_func = fval->Lookup("path_func", true);
|
||||
Val* log_local = fval->Lookup("log_local", true);
|
||||
Val* log_remote = fval->Lookup("log_remote", true);
|
||||
Val* interv = fval->Lookup("interv", true);
|
||||
Val* postprocessor = fval->Lookup("postprocessor", true);
|
||||
Val* config = fval->Lookup("config", true);
|
||||
|
||||
Filter* filter = new Filter;
|
||||
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
|
||||
// potentially rolling out fields.
|
||||
Val* include = fval->Lookup(rtype->FieldOffset("include"));
|
||||
Val* exclude = fval->Lookup(rtype->FieldOffset("exclude"));
|
||||
Val* include = fval->Lookup("include");
|
||||
Val* exclude = fval->Lookup("exclude");
|
||||
|
||||
filter->num_fields = 0;
|
||||
filter->fields = 0;
|
||||
|
@ -631,7 +630,7 @@ bool Manager::AddFilter(EnumVal* id, RecordVal* fval)
|
|||
}
|
||||
|
||||
// Get the path for the filter.
|
||||
Val* path_val = fval->Lookup(rtype->FieldOffset("path"));
|
||||
Val* path_val = fval->Lookup("path");
|
||||
|
||||
if ( path_val )
|
||||
{
|
||||
|
|
|
@ -242,17 +242,6 @@ public:
|
|||
* Note: Exactly one of the two FinishedRotation() methods must be
|
||||
* called by a writer's implementation of DoRotate() once rotation
|
||||
* 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();
|
||||
|
||||
|
|
|
@ -112,6 +112,9 @@ WriterFrontend::WriterFrontend(const WriterBackend::WriterInfo& arg_info, EnumVa
|
|||
write_buffer_pos = 0;
|
||||
info = new WriterBackend::WriterInfo(arg_info);
|
||||
|
||||
num_fields = 0;
|
||||
fields = 0;
|
||||
|
||||
const char* w = arg_writer->Type()->AsEnumType()->Lookup(arg_writer->InternalInt());
|
||||
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);
|
||||
|
||||
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) )
|
||||
{
|
||||
|
|
|
@ -233,6 +233,10 @@ DataSeries::DataSeries(WriterFrontend* frontend) : WriterBackend(frontend)
|
|||
ds_set_separator = ",";
|
||||
|
||||
ascii = new AsciiFormatter(this, AsciiFormatter::SeparatorInfo());
|
||||
|
||||
compress_type = Extent::compress_none;
|
||||
log_file = 0;
|
||||
log_output = 0;
|
||||
}
|
||||
|
||||
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 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) )
|
||||
{
|
||||
|
|
|
@ -16,7 +16,9 @@ using namespace writer;
|
|||
using threading::Value;
|
||||
using threading::Field;
|
||||
|
||||
SQLite::SQLite(WriterFrontend* frontend) : WriterBackend(frontend)
|
||||
SQLite::SQLite(WriterFrontend* frontend)
|
||||
: WriterBackend(frontend),
|
||||
fields(), num_fields(), db(), st()
|
||||
{
|
||||
set_separator.assign(
|
||||
(const char*) BifConst::LogSQLite::set_separator->Bytes(),
|
||||
|
@ -33,9 +35,7 @@ SQLite::SQLite(WriterFrontend* frontend) : WriterBackend(frontend)
|
|||
BifConst::LogSQLite::empty_field->Len()
|
||||
);
|
||||
|
||||
db = 0;
|
||||
io = new AsciiFormatter(this, AsciiFormatter::SeparatorInfo(set_separator, unset_field, empty_field));
|
||||
st = 0;
|
||||
}
|
||||
|
||||
SQLite::~SQLite()
|
||||
|
|
|
@ -782,7 +782,10 @@ int main(int argc, char** argv)
|
|||
bro_init_magic(&magic_desc_cookie, MAGIC_NONE);
|
||||
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
|
||||
// seed the PRNG. We should do this here (but at least Linux, FreeBSD
|
||||
|
|
|
@ -81,7 +81,7 @@ private:
|
|||
friend class ::RemoteSerializer;
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
|
@ -944,6 +944,13 @@ FILE* open_file(const char* filename, const char** full_filename, bool load_pkgs
|
|||
|
||||
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;
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
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