diff --git a/aux/broctl b/aux/broctl index 7ca51fc46c..81fa2d664a 160000 --- a/aux/broctl +++ b/aux/broctl @@ -1 +1 @@ -Subproject commit 7ca51fc46c5c3dd4f3d803e5c617c2e35129fb05 +Subproject commit 81fa2d664a7ef7306a03928484b10611fbe893b8 diff --git a/src/Conn.cc b/src/Conn.cc index d0a932e373..0098d297e0 100644 --- a/src/Conn.cc +++ b/src/Conn.cc @@ -27,6 +27,9 @@ void ConnectionTimer::Init(Connection* arg_conn, timer_func arg_timer, ConnectionTimer::~ConnectionTimer() { + if ( conn->RefCnt() < 1 ) + reporter->InternalError("reference count inconsistency in ~ConnectionTimer"); + conn->RemoveTimer(this); Unref(conn); } @@ -41,6 +44,9 @@ void ConnectionTimer::Dispatch(double t, int is_expire) conn->RemoveTimer(this); (conn->*timer)(t); + + if ( conn->RefCnt() < 1 ) + reporter->InternalError("reference count inconsistency in ConnectionTimer::Dispatch"); } IMPLEMENT_SERIAL(ConnectionTimer, SER_CONNECTION_TIMER); @@ -62,10 +68,7 @@ bool ConnectionTimer::DoSerialize(SerialInfo* info) const else if ( timer == timer_func(&Connection::RemoveConnectionTimer) ) type = 4; else - { - reporter->InternalWarning("unknown function in ConnectionTimer::DoSerialize()"); - return false; - } + reporter->InternalError("unknown function in ConnectionTimer::DoSerialize()"); return conn->Serialize(info) && SERIALIZE(type) && SERIALIZE(do_expire); } @@ -177,12 +180,7 @@ Connection::Connection(NetSessions* s, HashKey* k, double t, const ConnID* id, Connection::~Connection() { if ( ! finished ) - { - // TODO: not sure about this - reporter->InternalWarning( - "missing Connection::Done() before ~Connection"); - Done(); - } + reporter->InternalError("Done() not called before destruction of Connection"); CancelTimers(); @@ -793,7 +791,6 @@ void Connection::Describe(ODesc* d) const default: reporter->InternalError( "unhandled transport type in Connection::Describe"); - break; } d->SP(); diff --git a/src/Desc.cc b/src/Desc.cc index 2a44a65fdf..62c6130f40 100644 --- a/src/Desc.cc +++ b/src/Desc.cc @@ -65,20 +65,15 @@ void ODesc::PushIndent() void ODesc::PopIndent() { if ( --indent_level < 0 ) - { - indent_level = 0; - reporter->InternalWarning("ODesc::PopIndent underflow"); - } + reporter->InternalError("ODesc::PopIndent underflow"); + NL(); } void ODesc::PopIndentNoNL() { if ( --indent_level < 0 ) - { - indent_level = 0; - reporter->InternalWarning("ODesc::PopIndent underflow"); - } + reporter->InternalError("ODesc::PopIndent underflow"); } void ODesc::Add(const char* s, int do_indent) diff --git a/src/Event.cc b/src/Event.cc index 980180def6..0fb76d10bc 100644 --- a/src/Event.cc +++ b/src/Event.cc @@ -91,10 +91,7 @@ void EventMgr::QueueEvent(Event* event) void EventMgr::Dispatch() { if ( ! head ) - { - reporter->InternalWarning("EventMgr::Dispatch underflow"); - return; - } + reporter->InternalError("EventMgr::Dispatch underflow"); Event* current = head; diff --git a/src/File.cc b/src/File.cc index d28d0ca569..bf6a7e7f51 100644 --- a/src/File.cc +++ b/src/File.cc @@ -284,10 +284,7 @@ FILE* BroFile::BringIntoCache() char buf[256]; if ( f ) - { - reporter->InternalWarning("BroFile non-nil non-open file"); - return 0; - } + reporter->InternalError("BroFile non-nil non-open file"); if ( num_files_in_cache >= max_files_in_cache ) PurgeCache(); @@ -313,7 +310,7 @@ FILE* BroFile::BringIntoCache() } strerror_r(errno, buf, sizeof(buf)); - reporter->InternalWarning("can't open /dev/null: %s", buf); + reporter->Error("can't open /dev/null: %s", buf); return 0; } @@ -399,24 +396,15 @@ int BroFile::Close() void BroFile::Suspend() { if ( ! is_in_cache ) - { - reporter->InternalWarning("BroFile::Suspend() called for non-cached file"); - return; - } + reporter->InternalError("BroFile::Suspend() called for non-cached file"); if ( ! is_open ) - { - reporter->InternalWarning("BroFile::Suspend() called for non-open file"); - return; - } + reporter->InternalError("BroFile::Suspend() called for non-open file"); Unlink(); if ( ! f ) - { - reporter->InternalWarning("BroFile::Suspend() called for nil file"); - return; - } + reporter->InternalError("BroFile::Suspend() called for nil file"); if ( (position = ftell(f)) < 0 ) { diff --git a/src/Frag.cc b/src/Frag.cc index 5cfff270c7..199af78ca9 100644 --- a/src/Frag.cc +++ b/src/Frag.cc @@ -164,11 +164,13 @@ void FragReassembler::Weird(const char* name) const IP_Hdr hdr((const ip*)proto_hdr, false); s->Weird(name, &hdr); } + else if ( version == 6 ) { IP_Hdr hdr((const ip6_hdr*)proto_hdr, false, proto_hdr_len); s->Weird(name, &hdr); } + else { reporter->InternalWarning("Unexpected IP version in FragReassembler"); diff --git a/src/IP.h b/src/IP.h index fd7a6de266..fb936df1bc 100644 --- a/src/IP.h +++ b/src/IP.h @@ -182,6 +182,7 @@ public: reporter->InternalWarning("empty IPv6 header chain"); return false; } + return chain[chain.size()-1]->Type() == IPPROTO_FRAGMENT; } @@ -229,6 +230,7 @@ public: reporter->InternalWarning("empty IPv6 header chain"); return IPAddr(); } + return IPAddr(((const struct ip6_hdr*)(chain[0]->Data()))->ip6_src); } @@ -241,11 +243,13 @@ public: { if ( finalDst ) return IPAddr(*finalDst); + if ( chain.empty() ) { reporter->InternalWarning("empty IPv6 header chain"); return IPAddr(); } + return IPAddr(((const struct ip6_hdr*)(chain[0]->Data()))->ip6_dst); } @@ -461,9 +465,11 @@ public: { if ( ip4 ) return IPPROTO_RAW; + size_t i = ip6_hdrs->Size(); if ( i > 0 ) return (*ip6_hdrs)[i-1]->Type(); + return IPPROTO_NONE; } @@ -476,9 +482,11 @@ public: { if ( ip4 ) return ip4->ip_p; + size_t i = ip6_hdrs->Size(); if ( i > 0 ) return (*ip6_hdrs)[i-1]->NextHdr(); + return IPPROTO_NONE; } diff --git a/src/Reassem.cc b/src/Reassem.cc index df7e3568ee..19beaa0a16 100644 --- a/src/Reassem.cc +++ b/src/Reassem.cc @@ -19,7 +19,6 @@ DataBlock::DataBlock(const u_char* data, int size, int arg_seq, { seq = arg_seq; upper = seq + size; - block = new u_char[size]; memcpy((void*) block, (const void*) data, size); diff --git a/src/RemoteSerializer.cc b/src/RemoteSerializer.cc index bcf4b090b0..7d9c6163a0 100644 --- a/src/RemoteSerializer.cc +++ b/src/RemoteSerializer.cc @@ -3607,9 +3607,9 @@ bool SocketComm::ProcessParentMessage() default: InternalError("unknown msgstate"); - return false; } + // Cannot be reached. return false; } diff --git a/src/Reporter.h b/src/Reporter.h index 79eb21c1de..82e6cb575f 100644 --- a/src/Reporter.h +++ b/src/Reporter.h @@ -92,7 +92,7 @@ public: // dump after the message has been reported. void InternalError(const char* fmt, ...) FMT_ATTR; - // Reporter an internal analyzer error. That analyzer will not process + // Report an internal analyzer error. That analyzer will not process // any further input, but Bro otherwise continues normally. void InternalAnalyzerError(analyzer::Analyzer* a, const char* fmt, ...); diff --git a/src/analyzer/protocol/mime/MIME.cc b/src/analyzer/protocol/mime/MIME.cc index 8f3df63250..2128453b4c 100644 --- a/src/analyzer/protocol/mime/MIME.cc +++ b/src/analyzer/protocol/mime/MIME.cc @@ -557,12 +557,8 @@ void MIME_Entity::init() MIME_Entity::~MIME_Entity() { if ( ! end_of_data ) - { - // TODO: not sure about this - reporter->InternalWarning( + reporter->AnalyzerError(message ? message->GetAnalyzer() : 0, "missing MIME_Entity::EndOfData() before ~MIME_Entity"); - EndOfData(); - } delete current_header_line; Unref(content_type_str); diff --git a/src/analyzer/protocol/tcp/TCP.cc b/src/analyzer/protocol/tcp/TCP.cc index ca7fe073e8..cbf983b70a 100644 --- a/src/analyzer/protocol/tcp/TCP.cc +++ b/src/analyzer/protocol/tcp/TCP.cc @@ -1580,7 +1580,7 @@ BroFile* TCP_Analyzer::GetContentsFile(unsigned int direction) const default: break; } - reporter->Error("bad direction %u in TCP_Analyzer::GetContentsFile", + reporter->InternalWarning("bad direction %u in TCP_Analyzer::GetContentsFile", direction); return 0; } diff --git a/src/input/Manager.cc b/src/input/Manager.cc index 1f0201393f..a05eb59e99 100644 --- a/src/input/Manager.cc +++ b/src/input/Manager.cc @@ -46,6 +46,7 @@ static void delete_value_ptr_array(Value** vals, int num_fields) { for ( int i = 0; i < num_fields; ++i ) delete vals[i]; + delete [] vals; } diff --git a/src/threading/SerialTypes.cc b/src/threading/SerialTypes.cc index 6c9ddb8f30..a4f76a9b2d 100644 --- a/src/threading/SerialTypes.cc +++ b/src/threading/SerialTypes.cc @@ -296,7 +296,6 @@ bool Value::Read(SerializationFormat* fmt) default: reporter->InternalError("unsupported type %s in Value::Read", type_name(type)); - return false; } return false; @@ -402,7 +401,6 @@ bool Value::Write(SerializationFormat* fmt) const default: reporter->InternalError("unsupported type %s in Value::Write", type_name(type)); - return false; } return false;