mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 22:58:20 +00:00
Fix various potential memory leaks.
Though I expect most not to be exercised in practice.
This commit is contained in:
parent
c3a4454892
commit
0b97343ff7
29 changed files with 142 additions and 32 deletions
|
@ -99,8 +99,6 @@ void BroDoc::AddImport(const std::string& s)
|
||||||
|
|
||||||
if ( f && full_filename && subpath )
|
if ( f && full_filename && subpath )
|
||||||
{
|
{
|
||||||
fclose(f);
|
|
||||||
|
|
||||||
char* tmp = copy_string(full_filename);
|
char* tmp = copy_string(full_filename);
|
||||||
char* filename = basename(tmp);
|
char* filename = basename(tmp);
|
||||||
extern char* PACKAGE_LOADER;
|
extern char* PACKAGE_LOADER;
|
||||||
|
@ -139,6 +137,9 @@ void BroDoc::AddImport(const std::string& s)
|
||||||
fprintf(stderr, "Failed to document '@load %s' in file: %s\n",
|
fprintf(stderr, "Failed to document '@load %s' in file: %s\n",
|
||||||
s.c_str(), reST_filename.c_str());
|
s.c_str(), reST_filename.c_str());
|
||||||
|
|
||||||
|
if ( f )
|
||||||
|
fclose(f);
|
||||||
|
|
||||||
delete [] full_filename;
|
delete [] full_filename;
|
||||||
delete [] subpath;
|
delete [] subpath;
|
||||||
}
|
}
|
||||||
|
@ -559,7 +560,7 @@ static void WriteAnalyzerTagDefn(FILE* f, EnumType* e, const string& module)
|
||||||
e = new CommentedEnumType(e);
|
e = new CommentedEnumType(e);
|
||||||
e->SetTypeID(copy_string(tag_id.c_str()));
|
e->SetTypeID(copy_string(tag_id.c_str()));
|
||||||
|
|
||||||
ID* dummy_id = new ID(copy_string(tag_id.c_str()), SCOPE_GLOBAL, true);
|
ID* dummy_id = new ID(tag_id.c_str(), SCOPE_GLOBAL, true);
|
||||||
dummy_id->SetType(e);
|
dummy_id->SetType(e);
|
||||||
dummy_id->MakeType();
|
dummy_id->MakeType();
|
||||||
|
|
||||||
|
|
|
@ -527,7 +527,13 @@ Val* Connection::BuildVersionVal(const char* s, int len)
|
||||||
|
|
||||||
// We need at least a name.
|
// We need at least a name.
|
||||||
if ( ! name )
|
if ( ! name )
|
||||||
|
{
|
||||||
|
Unref(major);
|
||||||
|
Unref(minor);
|
||||||
|
Unref(minor2);
|
||||||
|
Unref(addl);
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
RecordVal* version = new RecordVal(software_version);
|
RecordVal* version = new RecordVal(software_version);
|
||||||
version->Assign(0, major ? major : new Val(-1, TYPE_INT));
|
version->Assign(0, major ? major : new Val(-1, TYPE_INT));
|
||||||
|
|
|
@ -304,6 +304,7 @@ DFA_State_Cache::~DFA_State_Cache()
|
||||||
{
|
{
|
||||||
assert(e->state);
|
assert(e->state);
|
||||||
delete e->hash;
|
delete e->hash;
|
||||||
|
Unref(e->state);
|
||||||
delete e;
|
delete e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -410,7 +411,10 @@ DFA_Machine::DFA_Machine(NFA_Machine* n, EquivClass* arg_ec)
|
||||||
(void) StateSetToDFA_State(state_set, start_state, ec);
|
(void) StateSetToDFA_State(state_set, start_state, ec);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
start_state = 0; // Jam
|
start_state = 0; // Jam
|
||||||
|
delete ns;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DFA_Machine::~DFA_Machine()
|
DFA_Machine::~DFA_Machine()
|
||||||
|
|
|
@ -79,6 +79,8 @@ void DebugLogger::EnableStreams(const char* s)
|
||||||
|
|
||||||
tok = strtok(0, ",");
|
tok = strtok(0, ",");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete [] tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebugLogger::Log(DebugStream stream, const char* fmt, ...)
|
void DebugLogger::Log(DebugStream stream, const char* fmt, ...)
|
||||||
|
|
|
@ -2964,6 +2964,7 @@ Val* IndexExpr::Eval(Frame* f) const
|
||||||
if ( v_v1->Size() != v_v2->Size() )
|
if ( v_v1->Size() != v_v2->Size() )
|
||||||
{
|
{
|
||||||
Error("size mismatch, boolean index and vector");
|
Error("size mismatch, boolean index and vector");
|
||||||
|
Unref(v_result);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3803,6 +3804,8 @@ Val* VectorConstructorExpr::InitVal(const BroType* t, Val* aggr) const
|
||||||
if ( ! v || ! vec->Assign(i, v) )
|
if ( ! v || ! vec->Assign(i, v) )
|
||||||
{
|
{
|
||||||
Error(fmt("initialization type mismatch at index %d", i), e);
|
Error(fmt("initialization type mismatch at index %d", i), e);
|
||||||
|
if ( ! aggr )
|
||||||
|
Unref(vec);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5159,6 +5162,7 @@ Val* ListExpr::InitVal(const BroType* t, Val* aggr) const
|
||||||
if ( exprs.length() != tl->length() )
|
if ( exprs.length() != tl->length() )
|
||||||
{
|
{
|
||||||
Error("index mismatch", t);
|
Error("index mismatch", t);
|
||||||
|
Unref(v);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -119,6 +119,7 @@ RETSIGTYPE watchdog(int /* signo */)
|
||||||
if ( pkt_dumper->IsError() )
|
if ( pkt_dumper->IsError() )
|
||||||
{
|
{
|
||||||
reporter->Error("watchdog: can't open watchdog-pkt.pcap for writing\n");
|
reporter->Error("watchdog: can't open watchdog-pkt.pcap for writing\n");
|
||||||
|
delete pkt_dumper;
|
||||||
pkt_dumper = 0;
|
pkt_dumper = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -624,6 +624,7 @@ SecondaryPath::SecondaryPath()
|
||||||
event_list.append(se);
|
event_list.append(se);
|
||||||
|
|
||||||
delete h;
|
delete h;
|
||||||
|
Unref(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2699,6 +2699,7 @@ bool RemoteSerializer::ProcessLogCreateWriter()
|
||||||
EnumVal* id_val = 0;
|
EnumVal* id_val = 0;
|
||||||
EnumVal* writer_val = 0;
|
EnumVal* writer_val = 0;
|
||||||
threading::Field** fields = 0;
|
threading::Field** fields = 0;
|
||||||
|
int delete_fields_up_to = -1;
|
||||||
|
|
||||||
BinarySerializationFormat fmt;
|
BinarySerializationFormat fmt;
|
||||||
fmt.StartRead(current_args->data, current_args->len);
|
fmt.StartRead(current_args->data, current_args->len);
|
||||||
|
@ -2721,8 +2722,11 @@ bool RemoteSerializer::ProcessLogCreateWriter()
|
||||||
{
|
{
|
||||||
fields[i] = new threading::Field;
|
fields[i] = new threading::Field;
|
||||||
if ( ! fields[i]->Read(&fmt) )
|
if ( ! fields[i]->Read(&fmt) )
|
||||||
|
{
|
||||||
|
delete_fields_up_to = i + 1;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fmt.EndRead();
|
fmt.EndRead();
|
||||||
|
|
||||||
|
@ -2731,7 +2735,10 @@ bool RemoteSerializer::ProcessLogCreateWriter()
|
||||||
|
|
||||||
if ( ! log_mgr->CreateWriter(id_val, writer_val, info, num_fields, fields,
|
if ( ! log_mgr->CreateWriter(id_val, writer_val, info, num_fields, fields,
|
||||||
true, false, true) )
|
true, false, true) )
|
||||||
|
{
|
||||||
|
delete_fields_up_to = num_fields;
|
||||||
goto error;
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
Unref(id_val);
|
Unref(id_val);
|
||||||
Unref(writer_val);
|
Unref(writer_val);
|
||||||
|
@ -2741,7 +2748,12 @@ bool RemoteSerializer::ProcessLogCreateWriter()
|
||||||
error:
|
error:
|
||||||
Unref(id_val);
|
Unref(id_val);
|
||||||
Unref(writer_val);
|
Unref(writer_val);
|
||||||
|
delete info;
|
||||||
|
|
||||||
|
for ( int i = 0; i < delete_fields_up_to; ++i )
|
||||||
|
delete fields[i];
|
||||||
|
|
||||||
|
delete fields;
|
||||||
Error("write error for creating writer");
|
Error("write error for creating writer");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -2780,9 +2792,16 @@ bool RemoteSerializer::ProcessLogWrite()
|
||||||
for ( int i = 0; i < num_fields; i++ )
|
for ( int i = 0; i < num_fields; i++ )
|
||||||
{
|
{
|
||||||
vals[i] = new threading::Value;
|
vals[i] = new threading::Value;
|
||||||
|
|
||||||
if ( ! vals[i]->Read(&fmt) )
|
if ( ! vals[i]->Read(&fmt) )
|
||||||
|
{
|
||||||
|
for ( int j = 0; j <= i; ++j )
|
||||||
|
delete vals[j];
|
||||||
|
|
||||||
|
delete vals;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
id_val = new EnumVal(id, BifType::Enum::Log::ID);
|
id_val = new EnumVal(id, BifType::Enum::Log::ID);
|
||||||
writer_val = new EnumVal(writer, BifType::Enum::Log::Writer);
|
writer_val = new EnumVal(writer, BifType::Enum::Log::Writer);
|
||||||
|
@ -4267,6 +4286,8 @@ bool SocketComm::AcceptConnection(int fd)
|
||||||
if ( ! peer->io->Init() )
|
if ( ! peer->io->Init() )
|
||||||
{
|
{
|
||||||
Error(fmt("can't init peer io: %s", peer->io->Error()), false);
|
Error(fmt("can't init peer io: %s", peer->io->Error()), false);
|
||||||
|
delete peer->io;
|
||||||
|
delete peer;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1226,6 +1226,7 @@ static bool val_to_maskedval(Val* v, maskedvalue_list* append_to,
|
||||||
|
|
||||||
default:
|
default:
|
||||||
rules_error("Wrong type of identifier");
|
rules_error("Wrong type of identifier");
|
||||||
|
delete mval;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1148,7 +1148,11 @@ Packet* Packet::Unserialize(UnserialInfo* info)
|
||||||
UNSERIALIZE(&tv_usec) &&
|
UNSERIALIZE(&tv_usec) &&
|
||||||
UNSERIALIZE(&len) &&
|
UNSERIALIZE(&len) &&
|
||||||
UNSERIALIZE(&p->link_type)) )
|
UNSERIALIZE(&p->link_type)) )
|
||||||
|
{
|
||||||
|
delete p;
|
||||||
|
delete hdr;
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
hdr->ts.tv_sec = tv_sec;
|
hdr->ts.tv_sec = tv_sec;
|
||||||
hdr->ts.tv_usec = tv_usec;
|
hdr->ts.tv_usec = tv_usec;
|
||||||
|
@ -1156,12 +1160,18 @@ Packet* Packet::Unserialize(UnserialInfo* info)
|
||||||
|
|
||||||
char* tag;
|
char* tag;
|
||||||
if ( ! info->s->Read((char**) &tag, 0, "tag") )
|
if ( ! info->s->Read((char**) &tag, 0, "tag") )
|
||||||
|
{
|
||||||
|
delete p;
|
||||||
|
delete hdr;
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
char* pkt;
|
char* pkt;
|
||||||
int caplen;
|
int caplen;
|
||||||
if ( ! info->s->Read((char**) &pkt, &caplen, "data") )
|
if ( ! info->s->Read((char**) &pkt, &caplen, "data") )
|
||||||
{
|
{
|
||||||
|
delete p;
|
||||||
|
delete hdr;
|
||||||
delete [] tag;
|
delete [] tag;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -788,6 +788,7 @@ bool SwitchStmt::AddCaseLabelMapping(const Val* v, int idx)
|
||||||
}
|
}
|
||||||
|
|
||||||
case_label_map.Insert(hk, new int(idx));
|
case_label_map.Insert(hk, new int(idx));
|
||||||
|
delete hk;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -416,8 +416,7 @@ void begin_func(ID* id, const char* module_name, function_flavor flavor,
|
||||||
if ( arg_id && ! arg_id->IsGlobal() )
|
if ( arg_id && ! arg_id->IsGlobal() )
|
||||||
arg_id->Error("argument name used twice");
|
arg_id->Error("argument name used twice");
|
||||||
|
|
||||||
arg_id = install_ID(copy_string(arg_i->id), module_name,
|
arg_id = install_ID(arg_i->id, module_name, false, false);
|
||||||
false, false);
|
|
||||||
arg_id->SetType(arg_i->type->Ref());
|
arg_id->SetType(arg_i->type->Ref());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,6 +110,10 @@ flow DHCP_Flow(is_orig: bool) {
|
||||||
connection()->bro_analyzer()->Conn(),
|
connection()->bro_analyzer()->Conn(),
|
||||||
dhcp_msg_val_->Ref(), host_name);
|
dhcp_msg_val_->Ref(), host_name);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
Unref(host_name);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -201,6 +205,9 @@ flow DHCP_Flow(is_orig: bool) {
|
||||||
dhcp_msg_val_->Ref(), host_name);
|
dhcp_msg_val_->Ref(), host_name);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
Unref(host_name);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -66,6 +66,8 @@ void Gnutella_Analyzer::Done()
|
||||||
ConnectionEvent(gnutella_establish, vl);
|
ConnectionEvent(gnutella_establish, vl);
|
||||||
else if ( ! Established () && gnutella_not_establish )
|
else if ( ! Established () && gnutella_not_establish )
|
||||||
ConnectionEvent(gnutella_not_establish, vl);
|
ConnectionEvent(gnutella_not_establish, vl);
|
||||||
|
else
|
||||||
|
delete_vals(vl);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( gnutella_partial_binary_msg )
|
if ( gnutella_partial_binary_msg )
|
||||||
|
|
|
@ -175,6 +175,9 @@ void Rsh_Analyzer::DeliverStream(int len, const u_char* data, bool orig)
|
||||||
|
|
||||||
else if ( rsh_reply )
|
else if ( rsh_reply )
|
||||||
ConnectionEvent(rsh_reply, vl);
|
ConnectionEvent(rsh_reply, vl);
|
||||||
|
|
||||||
|
else
|
||||||
|
delete_vals(vl);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Rsh_Analyzer::ClientUserName(const char* s)
|
void Rsh_Analyzer::ClientUserName(const char* s)
|
||||||
|
|
|
@ -831,7 +831,6 @@ int MIME_Entity::ParseContentEncodingField(MIME_Header* h)
|
||||||
int MIME_Entity::ParseFieldParameters(int len, const char* data)
|
int MIME_Entity::ParseFieldParameters(int len, const char* data)
|
||||||
{
|
{
|
||||||
data_chunk_t attr;
|
data_chunk_t attr;
|
||||||
BroString* val;
|
|
||||||
|
|
||||||
while ( 1 )
|
while ( 1 )
|
||||||
{
|
{
|
||||||
|
@ -864,11 +863,13 @@ int MIME_Entity::ParseFieldParameters(int len, const char* data)
|
||||||
data += offset;
|
data += offset;
|
||||||
len -= offset;
|
len -= offset;
|
||||||
|
|
||||||
|
BroString* val = 0;
|
||||||
// token or quoted-string
|
// token or quoted-string
|
||||||
offset = MIME_get_value(len, data, val);
|
offset = MIME_get_value(len, data, val);
|
||||||
if ( offset < 0 )
|
if ( offset < 0 )
|
||||||
{
|
{
|
||||||
IllegalFormat("value not found in parameter specification");
|
IllegalFormat("value not found in parameter specification");
|
||||||
|
delete val;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -129,15 +129,12 @@ int NetbiosSSN_Interpreter::ParseBroadcast(const u_char* data, int len,
|
||||||
data += dstname->Len()+1;
|
data += dstname->Len()+1;
|
||||||
len -= dstname->Len();
|
len -= dstname->Len();
|
||||||
|
|
||||||
if ( smb_session )
|
|
||||||
{
|
|
||||||
smb_session->Deliver(is_query, len, data);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
delete srcname;
|
delete srcname;
|
||||||
delete dstname;
|
delete dstname;
|
||||||
|
|
||||||
|
if ( smb_session )
|
||||||
|
smb_session->Deliver(is_query, len, data);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -251,6 +251,7 @@ int NFS_Interp::RPC_BuildReply(RPC_CallInfo* c, BifEnum::rpc_status rpc_status,
|
||||||
analyzer->ConnectionEvent(event, vl);
|
analyzer->ConnectionEvent(event, vl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Unref(reply);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -416,6 +416,7 @@ bool Manager::CreateEventStream(RecordVal* fval)
|
||||||
if ( etype->Flavor() != FUNC_FLAVOR_EVENT )
|
if ( etype->Flavor() != FUNC_FLAVOR_EVENT )
|
||||||
{
|
{
|
||||||
reporter->Error("stream event is a function, not an event");
|
reporter->Error("stream event is a function, not an event");
|
||||||
|
delete stream;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -424,18 +425,21 @@ bool Manager::CreateEventStream(RecordVal* fval)
|
||||||
if ( args->length() < 2 )
|
if ( args->length() < 2 )
|
||||||
{
|
{
|
||||||
reporter->Error("event takes not enough arguments");
|
reporter->Error("event takes not enough arguments");
|
||||||
|
delete stream;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! same_type((*args)[1], BifType::Enum::Input::Event, 0) )
|
if ( ! same_type((*args)[1], BifType::Enum::Input::Event, 0) )
|
||||||
{
|
{
|
||||||
reporter->Error("events second attribute must be of type Input::Event");
|
reporter->Error("events second attribute must be of type Input::Event");
|
||||||
|
delete stream;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! same_type((*args)[0], BifType::Record::Input::EventDescription, 0) )
|
if ( ! same_type((*args)[0], BifType::Record::Input::EventDescription, 0) )
|
||||||
{
|
{
|
||||||
reporter->Error("events first attribute must be of type Input::EventDescription");
|
reporter->Error("events first attribute must be of type Input::EventDescription");
|
||||||
|
delete stream;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -444,6 +448,7 @@ bool Manager::CreateEventStream(RecordVal* fval)
|
||||||
if ( args->length() != fields->NumFields() + 2 )
|
if ( args->length() != fields->NumFields() + 2 )
|
||||||
{
|
{
|
||||||
reporter->Error("event has wrong number of arguments");
|
reporter->Error("event has wrong number of arguments");
|
||||||
|
delete stream;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -452,6 +457,7 @@ bool Manager::CreateEventStream(RecordVal* fval)
|
||||||
if ( !same_type((*args)[i+2], fields->FieldType(i) ) )
|
if ( !same_type((*args)[i+2], fields->FieldType(i) ) )
|
||||||
{
|
{
|
||||||
reporter->Error("Incompatible type for event");
|
reporter->Error("Incompatible type for event");
|
||||||
|
delete stream;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -463,6 +469,7 @@ bool Manager::CreateEventStream(RecordVal* fval)
|
||||||
if ( args->length() != 3 )
|
if ( args->length() != 3 )
|
||||||
{
|
{
|
||||||
reporter->Error("event has wrong number of arguments");
|
reporter->Error("event has wrong number of arguments");
|
||||||
|
delete stream;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -475,6 +482,7 @@ bool Manager::CreateEventStream(RecordVal* fval)
|
||||||
reporter->Error("Incompatible type '%s':%s for event, which needs type '%s':%s\n",
|
reporter->Error("Incompatible type '%s':%s for event, which needs type '%s':%s\n",
|
||||||
type_name((*args)[2]->Tag()), desc1.Description(),
|
type_name((*args)[2]->Tag()), desc1.Description(),
|
||||||
type_name(fields->Tag()), desc2.Description());
|
type_name(fields->Tag()), desc2.Description());
|
||||||
|
delete stream;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -493,6 +501,7 @@ bool Manager::CreateEventStream(RecordVal* fval)
|
||||||
if ( status )
|
if ( status )
|
||||||
{
|
{
|
||||||
reporter->Error("Problem unrolling");
|
reporter->Error("Problem unrolling");
|
||||||
|
delete stream;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -560,12 +569,14 @@ bool Manager::CreateTableStream(RecordVal* fval)
|
||||||
if ( j >= num )
|
if ( j >= num )
|
||||||
{
|
{
|
||||||
reporter->Error("Table type has more indexes than index definition");
|
reporter->Error("Table type has more indexes than index definition");
|
||||||
|
delete stream;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! same_type(idx->FieldType(j), (*tl)[j]) )
|
if ( ! same_type(idx->FieldType(j), (*tl)[j]) )
|
||||||
{
|
{
|
||||||
reporter->Error("Table type does not match index type");
|
reporter->Error("Table type does not match index type");
|
||||||
|
delete stream;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -573,6 +584,7 @@ bool Manager::CreateTableStream(RecordVal* fval)
|
||||||
if ( num != j )
|
if ( num != j )
|
||||||
{
|
{
|
||||||
reporter->Error("Table has less elements than index definition");
|
reporter->Error("Table has less elements than index definition");
|
||||||
|
delete stream;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -589,6 +601,7 @@ bool Manager::CreateTableStream(RecordVal* fval)
|
||||||
if ( etype->Flavor() != FUNC_FLAVOR_EVENT )
|
if ( etype->Flavor() != FUNC_FLAVOR_EVENT )
|
||||||
{
|
{
|
||||||
reporter->Error("stream event is a function, not an event");
|
reporter->Error("stream event is a function, not an event");
|
||||||
|
delete stream;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -597,36 +610,42 @@ bool Manager::CreateTableStream(RecordVal* fval)
|
||||||
if ( args->length() != 4 )
|
if ( args->length() != 4 )
|
||||||
{
|
{
|
||||||
reporter->Error("Table event must take 4 arguments");
|
reporter->Error("Table event must take 4 arguments");
|
||||||
|
delete stream;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! same_type((*args)[0], BifType::Record::Input::TableDescription, 0) )
|
if ( ! same_type((*args)[0], BifType::Record::Input::TableDescription, 0) )
|
||||||
{
|
{
|
||||||
reporter->Error("table events first attribute must be of type Input::TableDescription");
|
reporter->Error("table events first attribute must be of type Input::TableDescription");
|
||||||
|
delete stream;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! same_type((*args)[1], BifType::Enum::Input::Event, 0) )
|
if ( ! same_type((*args)[1], BifType::Enum::Input::Event, 0) )
|
||||||
{
|
{
|
||||||
reporter->Error("table events second attribute must be of type Input::Event");
|
reporter->Error("table events second attribute must be of type Input::Event");
|
||||||
|
delete stream;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! same_type((*args)[2], idx) )
|
if ( ! same_type((*args)[2], idx) )
|
||||||
{
|
{
|
||||||
reporter->Error("table events index attributes do not match");
|
reporter->Error("table events index attributes do not match");
|
||||||
|
delete stream;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( want_record->InternalInt() == 1 && ! same_type((*args)[3], val) )
|
if ( want_record->InternalInt() == 1 && ! same_type((*args)[3], val) )
|
||||||
{
|
{
|
||||||
reporter->Error("table events value attributes do not match");
|
reporter->Error("table events value attributes do not match");
|
||||||
|
delete stream;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if ( want_record->InternalInt() == 0
|
else if ( want_record->InternalInt() == 0
|
||||||
&& !same_type((*args)[3], val->FieldType(0) ) )
|
&& !same_type((*args)[3], val->FieldType(0) ) )
|
||||||
{
|
{
|
||||||
reporter->Error("table events value attribute does not match");
|
reporter->Error("table events value attribute does not match");
|
||||||
|
delete stream;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -651,6 +670,7 @@ bool Manager::CreateTableStream(RecordVal* fval)
|
||||||
if ( status )
|
if ( status )
|
||||||
{
|
{
|
||||||
reporter->Error("Problem unrolling");
|
reporter->Error("Problem unrolling");
|
||||||
|
delete stream;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -320,6 +320,11 @@ bool Ascii::DoUpdate()
|
||||||
{
|
{
|
||||||
Error(Fmt("Not enough fields in line %s. Found %d fields, want positions %d and %d",
|
Error(Fmt("Not enough fields in line %s. Found %d fields, want positions %d and %d",
|
||||||
line.c_str(), pos, (*fit).position, (*fit).secondary_position));
|
line.c_str(), pos, (*fit).position, (*fit).secondary_position));
|
||||||
|
|
||||||
|
for ( int i = 0; i < fpos; i++ )
|
||||||
|
delete fields[i];
|
||||||
|
|
||||||
|
delete [] fields;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -212,6 +212,7 @@ threading::Value* Benchmark::EntryToVal(TypeTag type, TypeTag subtype)
|
||||||
if ( newval == 0 )
|
if ( newval == 0 )
|
||||||
{
|
{
|
||||||
Error("Error while reading set");
|
Error("Error while reading set");
|
||||||
|
delete val;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
lvals[pos] = newval;
|
lvals[pos] = newval;
|
||||||
|
@ -223,6 +224,7 @@ threading::Value* Benchmark::EntryToVal(TypeTag type, TypeTag subtype)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Error(Fmt("unsupported field format %d", type));
|
Error(Fmt("unsupported field format %d", type));
|
||||||
|
delete val;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -148,6 +148,7 @@ Value* SQLite::EntryToVal(sqlite3_stmt *st, const threading::Field *field, int p
|
||||||
if ( sqlite3_column_type(st, pos) != SQLITE_INTEGER )
|
if ( sqlite3_column_type(st, pos) != SQLITE_INTEGER )
|
||||||
{
|
{
|
||||||
Error("Invalid data type for boolean - expected Integer");
|
Error("Invalid data type for boolean - expected Integer");
|
||||||
|
delete val;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,6 +159,7 @@ Value* SQLite::EntryToVal(sqlite3_stmt *st, const threading::Field *field, int p
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Error(Fmt("Invalid value for boolean: %d", res));
|
Error(Fmt("Invalid value for boolean: %d", res));
|
||||||
|
delete val;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -220,12 +222,14 @@ Value* SQLite::EntryToVal(sqlite3_stmt *st, const threading::Field *field, int p
|
||||||
{
|
{
|
||||||
const char *text = (const char*) sqlite3_column_text(st, pos);
|
const char *text = (const char*) sqlite3_column_text(st, pos);
|
||||||
string s(text, sqlite3_column_bytes(st, pos));
|
string s(text, sqlite3_column_bytes(st, pos));
|
||||||
|
delete val;
|
||||||
val = io->ParseValue(s, "", field->type, field->subtype);
|
val = io->ParseValue(s, "", field->type, field->subtype);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Error(Fmt("unsupported field format %d", field->type));
|
Error(Fmt("unsupported field format %d", field->type));
|
||||||
|
delete val;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -257,6 +261,8 @@ bool SQLite::DoUpdate()
|
||||||
if ( mapping[j] != -1 )
|
if ( mapping[j] != -1 )
|
||||||
{
|
{
|
||||||
Error(Fmt("SQLite statement returns several columns with name %s! Cannot decide which to choose, aborting", name));
|
Error(Fmt("SQLite statement returns several columns with name %s! Cannot decide which to choose, aborting", name));
|
||||||
|
delete [] mapping;
|
||||||
|
delete [] submapping;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,6 +275,8 @@ bool SQLite::DoUpdate()
|
||||||
if ( submapping[j] != -1 )
|
if ( submapping[j] != -1 )
|
||||||
{
|
{
|
||||||
Error(Fmt("SQLite statement returns several columns with name %s! Cannot decide which to choose, aborting", name));
|
Error(Fmt("SQLite statement returns several columns with name %s! Cannot decide which to choose, aborting", name));
|
||||||
|
delete [] mapping;
|
||||||
|
delete [] submapping;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -282,6 +290,8 @@ bool SQLite::DoUpdate()
|
||||||
if ( mapping[i] == -1 )
|
if ( mapping[i] == -1 )
|
||||||
{
|
{
|
||||||
Error(Fmt("Required field %s not found after SQLite statement", fields[i]->name));
|
Error(Fmt("Required field %s not found after SQLite statement", fields[i]->name));
|
||||||
|
delete [] mapping;
|
||||||
|
delete [] submapping;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -295,20 +305,28 @@ bool SQLite::DoUpdate()
|
||||||
{
|
{
|
||||||
ofields[j] = EntryToVal(st, fields[j], mapping[j], submapping[j]);
|
ofields[j] = EntryToVal(st, fields[j], mapping[j], submapping[j]);
|
||||||
if ( ofields[j] == 0 )
|
if ( ofields[j] == 0 )
|
||||||
|
{
|
||||||
|
for ( int k = 0; k < j; ++k )
|
||||||
|
delete ofields[k];
|
||||||
|
|
||||||
|
delete [] ofields;
|
||||||
|
delete [] mapping;
|
||||||
|
delete [] submapping;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SendEntry(ofields);
|
SendEntry(ofields);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete [] mapping;
|
||||||
|
delete [] submapping;
|
||||||
|
|
||||||
if ( checkError(errorcode) ) // check the last error code returned by sqlite
|
if ( checkError(errorcode) ) // check the last error code returned by sqlite
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
EndCurrentSend();
|
EndCurrentSend();
|
||||||
|
|
||||||
delete [] mapping;
|
|
||||||
delete [] submapping;
|
|
||||||
|
|
||||||
if ( checkError(sqlite3_reset(st)) )
|
if ( checkError(sqlite3_reset(st)) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
@ -132,6 +132,7 @@ WriterFrontend::~WriterFrontend()
|
||||||
Unref(stream);
|
Unref(stream);
|
||||||
Unref(writer);
|
Unref(writer);
|
||||||
delete info;
|
delete info;
|
||||||
|
delete [] name;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WriterFrontend::Stop()
|
void WriterFrontend::Stop()
|
||||||
|
|
|
@ -222,7 +222,7 @@ void usage()
|
||||||
|
|
||||||
fprintf(stderr, " $BROPATH | file search path (%s)\n", bro_path());
|
fprintf(stderr, " $BROPATH | file search path (%s)\n", bro_path());
|
||||||
fprintf(stderr, " $BROMAGIC | libmagic mime magic database search path (%s)\n", bro_magic_path());
|
fprintf(stderr, " $BROMAGIC | libmagic mime magic database search path (%s)\n", bro_magic_path());
|
||||||
fprintf(stderr, " $BRO_PREFIXES | prefix list (%s)\n", bro_prefixes());
|
fprintf(stderr, " $BRO_PREFIXES | prefix list (%s)\n", bro_prefixes().c_str());
|
||||||
fprintf(stderr, " $BRO_DNS_FAKE | disable DNS lookups (%s)\n", bro_dns_fake());
|
fprintf(stderr, " $BRO_DNS_FAKE | disable DNS lookups (%s)\n", bro_dns_fake());
|
||||||
fprintf(stderr, " $BRO_SEED_FILE | file to load seeds from (not set)\n");
|
fprintf(stderr, " $BRO_SEED_FILE | file to load seeds from (not set)\n");
|
||||||
fprintf(stderr, " $BRO_LOG_SUFFIX | ASCII log file extension (.%s)\n", logging::writer::Ascii::LogExt().c_str());
|
fprintf(stderr, " $BRO_LOG_SUFFIX | ASCII log file extension (.%s)\n", logging::writer::Ascii::LogExt().c_str());
|
||||||
|
|
|
@ -188,5 +188,11 @@ CardinalityCounter* CardinalityCounter::Unserialize(UnserialInfo* info)
|
||||||
buckets[i] = (uint8)c;
|
buckets[i] = (uint8)c;
|
||||||
}
|
}
|
||||||
|
|
||||||
return valid ? c : 0;
|
if ( ! valid )
|
||||||
|
{
|
||||||
|
delete c;
|
||||||
|
c = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return c;
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,6 +161,7 @@ void TopkVal::Merge(const TopkVal* value, bool doPrune)
|
||||||
Element* e = b->elements.front();
|
Element* e = b->elements.front();
|
||||||
HashKey* key = GetHash(e->value);
|
HashKey* key = GetHash(e->value);
|
||||||
elementDict->RemoveEntry(key);
|
elementDict->RemoveEntry(key);
|
||||||
|
delete key;
|
||||||
delete e;
|
delete e;
|
||||||
|
|
||||||
b->elements.pop_front();
|
b->elements.pop_front();
|
||||||
|
@ -323,6 +324,7 @@ uint64_t TopkVal::GetCount(Val* value) const
|
||||||
{
|
{
|
||||||
HashKey* key = GetHash(value);
|
HashKey* key = GetHash(value);
|
||||||
Element* e = (Element*) elementDict->Lookup(key);
|
Element* e = (Element*) elementDict->Lookup(key);
|
||||||
|
delete key;
|
||||||
|
|
||||||
if ( e == 0 )
|
if ( e == 0 )
|
||||||
{
|
{
|
||||||
|
@ -330,7 +332,6 @@ uint64_t TopkVal::GetCount(Val* value) const
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete key;
|
|
||||||
return e->parent->count;
|
return e->parent->count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -338,6 +339,7 @@ uint64_t TopkVal::GetEpsilon(Val* value) const
|
||||||
{
|
{
|
||||||
HashKey* key = GetHash(value);
|
HashKey* key = GetHash(value);
|
||||||
Element* e = (Element*) elementDict->Lookup(key);
|
Element* e = (Element*) elementDict->Lookup(key);
|
||||||
|
delete key;
|
||||||
|
|
||||||
if ( e == 0 )
|
if ( e == 0 )
|
||||||
{
|
{
|
||||||
|
@ -345,7 +347,6 @@ uint64_t TopkVal::GetEpsilon(Val* value) const
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete key;
|
|
||||||
return e->epsilon;
|
return e->epsilon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -126,6 +126,8 @@ struct Value {
|
||||||
char* data;
|
char* data;
|
||||||
int length;
|
int length;
|
||||||
} string_val;
|
} string_val;
|
||||||
|
|
||||||
|
_val() { memset(this, 0, sizeof(_val)); }
|
||||||
} val;
|
} val;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
17
src/util.cc
17
src/util.cc
|
@ -902,24 +902,17 @@ const char* bro_magic_path()
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* bro_prefixes()
|
string bro_prefixes()
|
||||||
{
|
{
|
||||||
int len = 1; // room for \0
|
string rval;
|
||||||
loop_over_list(prefixes, i)
|
|
||||||
len += strlen(prefixes[i]) + 1;
|
|
||||||
|
|
||||||
char* p = new char[len];
|
|
||||||
|
|
||||||
loop_over_list(prefixes, j)
|
loop_over_list(prefixes, j)
|
||||||
if ( j == 0 )
|
if ( j == 0 )
|
||||||
strcpy(p, prefixes[j]);
|
rval.append(prefixes[j]);
|
||||||
else
|
else
|
||||||
{
|
rval.append(":").append(prefixes[j]);
|
||||||
strcat(p, ":");
|
|
||||||
strcat(p, prefixes[j]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return p;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* PACKAGE_LOADER = "__load__.bro";
|
const char* PACKAGE_LOADER = "__load__.bro";
|
||||||
|
|
|
@ -204,7 +204,7 @@ extern int int_list_cmp(const void* v1, const void* v2);
|
||||||
|
|
||||||
extern const char* bro_path();
|
extern const char* bro_path();
|
||||||
extern const char* bro_magic_path();
|
extern const char* bro_magic_path();
|
||||||
extern const char* bro_prefixes();
|
extern std::string bro_prefixes();
|
||||||
std::string dot_canon(std::string path, std::string file, std::string prefix = "");
|
std::string dot_canon(std::string path, std::string file, std::string prefix = "");
|
||||||
const char* normalize_path(const char* path);
|
const char* normalize_path(const char* path);
|
||||||
void get_script_subpath(const std::string& full_filename, const char** subpath);
|
void get_script_subpath(const std::string& full_filename, const char** subpath);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue