diff --git a/src/analyzer/Analyzer.cc b/src/analyzer/Analyzer.cc index 6f109c4b72..dd21861125 100644 --- a/src/analyzer/Analyzer.cc +++ b/src/analyzer/Analyzer.cc @@ -124,11 +124,11 @@ void Analyzer::CtorInit(const Tag& arg_tag, Connection* arg_conn) skip = false; finished = false; removing = false; - parent = 0; - orig_supporters = 0; - resp_supporters = 0; - signature = 0; - output_handler = 0; + parent = nullptr; + orig_supporters = nullptr; + resp_supporters = nullptr; + signature = nullptr; + output_handler = nullptr; } Analyzer::~Analyzer() @@ -138,7 +138,7 @@ Analyzer::~Analyzer() LOOP_OVER_CHILDREN(i) delete *i; - SupportAnalyzer* next = 0; + SupportAnalyzer* next = nullptr; for ( SupportAnalyzer* a = orig_supporters; a; a = next ) { @@ -501,7 +501,7 @@ Analyzer* Analyzer::FindChild(ID arg_id) return child; } - return 0; + return nullptr; } Analyzer* Analyzer::FindChild(Tag arg_tag) @@ -523,13 +523,13 @@ Analyzer* Analyzer::FindChild(Tag arg_tag) return child; } - return 0; + return nullptr; } Analyzer* Analyzer::FindChild(const char* name) { Tag tag = analyzer_mgr->GetComponentTag(name); - return tag ? FindChild(tag) : 0; + return tag ? FindChild(tag) : nullptr; } void Analyzer::DeleteChild(analyzer_list::iterator i) @@ -570,7 +570,7 @@ void Analyzer::AddSupportAnalyzer(SupportAnalyzer* analyzer) analyzer->IsOrig() ? &orig_supporters : &resp_supporters; // Find end of the list. - SupportAnalyzer* prev = 0; + SupportAnalyzer* prev = nullptr; SupportAnalyzer* s; for ( s = *head; s; prev = s, s = s->sibling ) ; @@ -621,7 +621,7 @@ SupportAnalyzer* Analyzer::FirstSupportAnalyzer(bool orig) SupportAnalyzer* sa = orig ? orig_supporters : resp_supporters; if ( ! sa ) - return 0; + return nullptr; if ( ! sa->Removing() ) return sa; @@ -922,7 +922,7 @@ void TransportLayerAnalyzer::SetContentsFile(unsigned int /* direction */, BroFile* TransportLayerAnalyzer::GetContentsFile(unsigned int /* direction */) const { reporter->Error("analyzer type does not support writing to a contents file"); - return 0; + return nullptr; } void TransportLayerAnalyzer::PacketContents(const u_char* data, int len) diff --git a/src/analyzer/Analyzer.h b/src/analyzer/Analyzer.h index 4d25fccb27..a4bd7b7a20 100644 --- a/src/analyzer/Analyzer.h +++ b/src/analyzer/Analyzer.h @@ -152,7 +152,7 @@ public: * @param caplen The packet's capture length, if available. */ void NextPacket(int len, const u_char* data, bool is_orig, - uint64_t seq = -1, const IP_Hdr* ip = 0, int caplen = 0); + uint64_t seq = -1, const IP_Hdr* ip = nullptr, int caplen = 0); /** * Passes stream input to the analyzer for processing. The analyzer @@ -528,7 +528,7 @@ public: * @param len If \a data is given, the length of it. */ virtual void ProtocolViolation(const char* reason, - const char* data = 0, int len = 0); + const char* data = nullptr, int len = 0); /** * Returns true if ProtocolConfirmation() has been called at least @@ -558,13 +558,13 @@ public: * Convenience function that forwards directly to the corresponding * Connection::Event(). */ - void Event(EventHandlerPtr f, const char* name = 0); + void Event(EventHandlerPtr f, const char* name = nullptr); /** * Convenience function that forwards directly to the corresponding * Connection::Event(). */ - void Event(EventHandlerPtr f, Val* v1, Val* v2 = 0); + void Event(EventHandlerPtr f, Val* v1, Val* v2 = nullptr); /** * Convenience function that forwards directly to @@ -796,7 +796,7 @@ public: * connection originator side, and otherwise for the responder side. */ SupportAnalyzer(const char* name, Connection* conn, bool arg_orig) - : Analyzer(name, conn) { orig = arg_orig; sibling = 0; } + : Analyzer(name, conn) { orig = arg_orig; sibling = nullptr; } /** * Destructor. @@ -879,7 +879,7 @@ public: * @param conn The connection the analyzer is associated with. */ TransportLayerAnalyzer(const char* name, Connection* conn) - : Analyzer(name, conn) { pia = 0; } + : Analyzer(name, conn) { pia = nullptr; } /** * Overridden from parent class. diff --git a/src/analyzer/Manager.cc b/src/analyzer/Manager.cc index 667f371407..948e2d09b2 100644 --- a/src/analyzer/Manager.cc +++ b/src/analyzer/Manager.cc @@ -292,17 +292,17 @@ Analyzer* Manager::InstantiateAnalyzer(const Tag& tag, Connection* conn) if ( ! c ) { reporter->InternalWarning("request to instantiate unknown analyzer"); - return 0; + return nullptr; } if ( ! c->Enabled() ) - return 0; + return nullptr; if ( ! c->Factory() ) { reporter->InternalWarning("analyzer %s cannot be instantiated dynamically", GetComponentName(tag).c_str()); - return 0; + return nullptr; } Analyzer* a = c->Factory()(conn); @@ -310,7 +310,7 @@ Analyzer* Manager::InstantiateAnalyzer(const Tag& tag, Connection* conn) if ( ! a ) { reporter->InternalWarning("analyzer instantiation failed"); - return 0; + return nullptr; } a->SetAnalyzerTag(tag); @@ -321,12 +321,12 @@ Analyzer* Manager::InstantiateAnalyzer(const Tag& tag, Connection* conn) Analyzer* Manager::InstantiateAnalyzer(const char* name, Connection* conn) { Tag tag = GetComponentTag(name); - return tag ? InstantiateAnalyzer(tag, conn) : 0; + return tag ? InstantiateAnalyzer(tag, conn) : nullptr; } Manager::tag_set* Manager::LookupPort(TransportProto proto, uint32_t port, bool add_if_not_found) { - analyzer_map_by_port* m = 0; + analyzer_map_by_port* m = nullptr; switch ( proto ) { case TRANSPORT_TCP: @@ -339,7 +339,7 @@ Manager::tag_set* Manager::LookupPort(TransportProto proto, uint32_t port, bool default: reporter->InternalWarning("unsupported transport protocol in analyzer::Manager::LookupPort"); - return 0; + return nullptr; } analyzer_map_by_port::const_iterator i = m->find(port); @@ -348,7 +348,7 @@ Manager::tag_set* Manager::LookupPort(TransportProto proto, uint32_t port, bool return i->second; if ( ! add_if_not_found ) - return 0; + return nullptr; tag_set* l = new tag_set; m->insert(std::make_pair(port, l)); @@ -362,11 +362,11 @@ Manager::tag_set* Manager::LookupPort(PortVal* val, bool add_if_not_found) bool Manager::BuildInitialAnalyzerTree(Connection* conn) { - tcp::TCP_Analyzer* tcp = 0; - udp::UDP_Analyzer* udp = 0; - icmp::ICMP_Analyzer* icmp = 0; - TransportLayerAnalyzer* root = 0; - pia::PIA* pia = 0; + tcp::TCP_Analyzer* tcp = nullptr; + udp::UDP_Analyzer* udp = nullptr; + icmp::ICMP_Analyzer* icmp = nullptr; + TransportLayerAnalyzer* root = nullptr; + pia::PIA* pia = nullptr; bool check_port = false; switch ( conn->ConnTransport() ) { @@ -628,7 +628,7 @@ bool Manager::ApplyScheduledAnalyzers(Connection* conn, bool init, TransportLaye EnumVal* tag = it->AsEnumVal(); Ref(tag); - conn->Event(scheduled_analyzer_applied, 0, tag); + conn->Event(scheduled_analyzer_applied, nullptr, tag); DBG_ANALYZER_ARGS(conn, "activated %s analyzer as scheduled", analyzer_mgr->GetComponentName(*it).c_str()); diff --git a/src/analyzer/Manager.h b/src/analyzer/Manager.h index fe32e43be9..084f4535fb 100644 --- a/src/analyzer/Manager.h +++ b/src/analyzer/Manager.h @@ -311,7 +311,7 @@ public: * * @return True if at least one scheduled analyzer was found. */ - bool ApplyScheduledAnalyzers(Connection* conn, bool init_and_event = true, TransportLayerAnalyzer* parent = 0); + bool ApplyScheduledAnalyzers(Connection* conn, bool init_and_event = true, TransportLayerAnalyzer* parent = nullptr); /** * Schedules a particular analyzer for an upcoming connection. Once diff --git a/src/analyzer/protocol/bittorrent/BitTorrentTracker.cc b/src/analyzer/protocol/bittorrent/BitTorrentTracker.cc index 7b0d8aedbb..d4ee18edab 100644 --- a/src/analyzer/protocol/bittorrent/BitTorrentTracker.cc +++ b/src/analyzer/protocol/bittorrent/BitTorrentTracker.cc @@ -15,7 +15,7 @@ using namespace analyzer::bittorrent; -static TableType* bt_tracker_headers = 0; +static TableType* bt_tracker_headers = nullptr; static RecordType* bittorrent_peer; static TableType* bittorrent_peer_set; static RecordType* bittorrent_benc_value; @@ -44,7 +44,7 @@ BitTorrentTracker_Analyzer::BitTorrentTracker_Analyzer(Connection* c) req_buf[sizeof(req_buf) - 1] = 0; req_buf_pos = req_buf; req_buf_len = 0; - req_val_uri = 0; + req_val_uri = nullptr; req_val_headers = new TableVal({NewRef{}, bt_tracker_headers}); res_state = BTT_RES_STATUS; @@ -230,16 +230,16 @@ void BitTorrentTracker_Analyzer::InitBencParser(void) benc_count.clear(); benc_state = BENC_STATE_EMPTY; - benc_raw = 0; + benc_raw = nullptr; benc_raw_type = BENC_TYPE_NONE; benc_raw_len = 0; - benc_key = 0; + benc_key = nullptr; benc_key_len = 0; - benc_strlen = 0; - benc_str = 0; + benc_strlen = nullptr; + benc_str = nullptr; benc_str_len = 0; benc_str_have = 0; - benc_int = 0; + benc_int = nullptr; benc_int_val = 0; } @@ -353,8 +353,8 @@ void BitTorrentTracker_Analyzer::EmitRequest(void) IntrusivePtr{AdoptRef{}, req_val_headers} ); - req_val_uri = 0; - req_val_headers = 0; + req_val_uri = nullptr; + req_val_headers = nullptr; } bool BitTorrentTracker_Analyzer::ParseResponse(char* line) @@ -406,7 +406,7 @@ bool BitTorrentTracker_Analyzer::ParseResponse(char* line) IntrusivePtr{AdoptRef{}, val_mgr->GetCount(res_status)}, IntrusivePtr{AdoptRef{}, res_val_headers} ); - res_val_headers = 0; + res_val_headers = nullptr; res_buf_pos = res_buf + res_buf_len; res_state = BTT_RES_DONE; } @@ -481,7 +481,7 @@ void BitTorrentTracker_Analyzer::ResponseBenc(int name_len, char* name, RecordVal* peer = new RecordVal(bittorrent_peer); peer->Assign(0, make_intrusive(ad)); peer->Assign(1, val_mgr->GetPort(pt, TRANSPORT_TCP)); - res_val_peers->Assign(peer, 0); + res_val_peers->Assign(peer, nullptr); Unref(peer); } @@ -617,9 +617,9 @@ int BitTorrentTracker_Analyzer::ResponseParseBenc(void) ResponseBenc(benc_key_len, benc_key, benc_raw_type, benc_raw_len, benc_raw); - benc_key = 0; + benc_key = nullptr; benc_key_len = 0; - benc_raw = 0; + benc_raw = nullptr; benc_raw_len = 0; benc_raw_type = BENC_TYPE_NONE; } @@ -686,7 +686,7 @@ int BitTorrentTracker_Analyzer::ResponseParseBenc(void) ResponseBenc(benc_key_len, benc_key, BENC_TYPE_INT, benc_int_val); - benc_key = 0; + benc_key = nullptr; benc_key_len = 0; } } @@ -764,7 +764,7 @@ int BitTorrentTracker_Analyzer::ResponseParseBenc(void) BENC_TYPE_STR, benc_str_len, benc_str); benc_key_len = 0; - benc_key = 0; + benc_key = nullptr; } if ( ! benc_str_len ) @@ -796,7 +796,7 @@ void BitTorrentTracker_Analyzer::EmitResponse(void) IntrusivePtr{AdoptRef{}, res_val_benc} ); - res_val_headers = 0; - res_val_peers = 0; - res_val_benc = 0; + res_val_headers = nullptr; + res_val_peers = nullptr; + res_val_benc = nullptr; } diff --git a/src/analyzer/protocol/conn-size/functions.bif b/src/analyzer/protocol/conn-size/functions.bif index f74464aef9..f6da9c61a8 100644 --- a/src/analyzer/protocol/conn-size/functions.bif +++ b/src/analyzer/protocol/conn-size/functions.bif @@ -7,7 +7,7 @@ static analyzer::Analyzer* GetConnsizeAnalyzer(Val* cid) { Connection* c = sessions->FindConnection(cid); if ( ! c ) - return 0; + return nullptr; analyzer::Analyzer* a = c->FindAnalyzer("CONNSIZE"); if ( ! a ) diff --git a/src/analyzer/protocol/dns/DNS.cc b/src/analyzer/protocol/dns/DNS.cc index 8ad9d796ce..5c041a09d8 100644 --- a/src/analyzer/protocol/dns/DNS.cc +++ b/src/analyzer/protocol/dns/DNS.cc @@ -545,7 +545,7 @@ bool DNS_Interpreter::ParseRR_Name(DNS_MsgInfo* msg, default: analyzer->Conn()->Internal("DNS_RR_bad_name"); - reply_event = 0; + reply_event = nullptr; } if ( reply_event && ! msg->skip_event ) @@ -757,7 +757,7 @@ bool DNS_Interpreter::ParseRR_TSIG(DNS_MsgInfo* msg, ExtractOctets(data, len, dns_TSIG_addl ? &request_MAC : nullptr); unsigned int orig_id = ExtractShort(data, len); unsigned int rr_error = ExtractShort(data, len); - ExtractOctets(data, len, 0); // Other Data + ExtractOctets(data, len, nullptr); // Other Data if ( dns_TSIG_addl ) { @@ -1256,7 +1256,7 @@ static StringVal* extract_char_string(analyzer::Analyzer* analyzer, const u_char*& data, int& len, int& rdlen) { if ( rdlen <= 0 ) - return 0; + return nullptr; uint8_t str_size = data[0]; @@ -1267,7 +1267,7 @@ static StringVal* extract_char_string(analyzer::Analyzer* analyzer, if ( str_size > rdlen ) { analyzer->Weird("DNS_TXT_char_str_past_rdlen"); - return 0; + return nullptr; } StringVal* rval = new StringVal(str_size, @@ -1428,7 +1428,7 @@ DNS_MsgInfo::DNS_MsgInfo(DNS_RawMsgHdr* hdr, int arg_is_query) id = ntohs(hdr->id); is_query = arg_is_query; - query_name = 0; + query_name = nullptr; atype = TYPE_ALL; aclass = 0; ttl = 0; @@ -1612,7 +1612,7 @@ Contents_DNS::Contents_DNS(Connection* conn, bool orig, { interp = arg_interp; - msg_buf = 0; + msg_buf = nullptr; buf_n = buf_len = msg_size = 0; state = DNS_LEN_HI; } @@ -1685,7 +1685,7 @@ void Contents_DNS::DeliverStream(int len, const u_char* data, bool orig) // Haven't filled up the message buffer yet, no more to do. return; - ForwardPacket(msg_size, msg_buf, orig, -1, 0, 0); + ForwardPacket(msg_size, msg_buf, orig, -1, nullptr, 0); buf_n = 0; state = DNS_LEN_HI; @@ -1699,7 +1699,7 @@ DNS_Analyzer::DNS_Analyzer(Connection* conn) : tcp::TCP_ApplicationAnalyzer("DNS", conn) { interp = new DNS_Interpreter(this); - contents_dns_orig = contents_dns_resp = 0; + contents_dns_orig = contents_dns_resp = nullptr; if ( Conn()->ConnTransport() == TRANSPORT_TCP ) { diff --git a/src/analyzer/protocol/dns/Plugin.cc b/src/analyzer/protocol/dns/Plugin.cc index 4aa46499c0..4aceaf0ff4 100644 --- a/src/analyzer/protocol/dns/Plugin.cc +++ b/src/analyzer/protocol/dns/Plugin.cc @@ -12,7 +12,7 @@ public: plugin::Configuration Configure() override { AddComponent(new ::analyzer::Component("DNS", ::analyzer::dns::DNS_Analyzer::Instantiate)); - AddComponent(new ::analyzer::Component("Contents_DNS", 0)); + AddComponent(new ::analyzer::Component("Contents_DNS", nullptr)); plugin::Configuration config; config.name = "Zeek::DNS"; diff --git a/src/analyzer/protocol/finger/Finger.cc b/src/analyzer/protocol/finger/Finger.cc index 1beba6947d..6fa54964a3 100644 --- a/src/analyzer/protocol/finger/Finger.cc +++ b/src/analyzer/protocol/finger/Finger.cc @@ -60,7 +60,7 @@ void Finger_Analyzer::DeliverStream(int length, const u_char* data, bool is_orig assert(line <= end_of_line); size_t n = end_of_line >= line ? end_of_line - line : 0; // just to be sure if assertions aren't on. const char* at = reinterpret_cast(memchr(line, '@', n)); - const char* host = 0; + const char* host = nullptr; if ( ! at ) at = host = end_of_line; else diff --git a/src/analyzer/protocol/ftp/FTP.cc b/src/analyzer/protocol/ftp/FTP.cc index 7957bb01be..31eaa481d1 100644 --- a/src/analyzer/protocol/ftp/FTP.cc +++ b/src/analyzer/protocol/ftp/FTP.cc @@ -204,7 +204,7 @@ void FTP_ADAT_Analyzer::DeliverStream(int len, const u_char* data, bool orig) const char* line = (const char*) data; const char* end_of_line = line + len; - BroString* decoded_adat = 0; + BroString* decoded_adat = nullptr; if ( orig ) { @@ -217,7 +217,7 @@ void FTP_ADAT_Analyzer::DeliverStream(int len, const u_char* data, bool orig) { line = skip_whitespace(line + cmd_len, end_of_line); StringVal encoded(end_of_line - line, line); - decoded_adat = decode_base64(encoded.AsString(), 0, Conn()); + decoded_adat = decode_base64(encoded.AsString(), nullptr, Conn()); if ( first_token ) { @@ -247,7 +247,7 @@ void FTP_ADAT_Analyzer::DeliverStream(int len, const u_char* data, bool orig) // Doesn't look like TLS/SSL, so done analyzing. done = true; delete decoded_adat; - decoded_adat = 0; + decoded_adat = nullptr; } } @@ -292,7 +292,7 @@ void FTP_ADAT_Analyzer::DeliverStream(int len, const u_char* data, bool orig) { line += 5; StringVal encoded(end_of_line - line, line); - decoded_adat = decode_base64(encoded.AsString(), 0, Conn()); + decoded_adat = decode_base64(encoded.AsString(), nullptr, Conn()); } break; diff --git a/src/analyzer/protocol/ftp/Plugin.cc b/src/analyzer/protocol/ftp/Plugin.cc index 49eef6c281..b7743355a7 100644 --- a/src/analyzer/protocol/ftp/Plugin.cc +++ b/src/analyzer/protocol/ftp/Plugin.cc @@ -12,7 +12,7 @@ public: plugin::Configuration Configure() override { AddComponent(new ::analyzer::Component("FTP", ::analyzer::ftp::FTP_Analyzer::Instantiate)); - AddComponent(new ::analyzer::Component("FTP_ADAT", 0)); + AddComponent(new ::analyzer::Component("FTP_ADAT", nullptr)); plugin::Configuration config; config.name = "Zeek::FTP"; diff --git a/src/analyzer/protocol/gnutella/Gnutella.cc b/src/analyzer/protocol/gnutella/Gnutella.cc index e22a5ad755..a6d36218c8 100644 --- a/src/analyzer/protocol/gnutella/Gnutella.cc +++ b/src/analyzer/protocol/gnutella/Gnutella.cc @@ -40,7 +40,7 @@ Gnutella_Analyzer::Gnutella_Analyzer(Connection* conn) new_state = 0; sent_establish = 0; - ms = 0; + ms = nullptr; orig_msg_state = new GnutellaMsgState(); resp_msg_state = new GnutellaMsgState(); diff --git a/src/analyzer/protocol/http/HTTP.cc b/src/analyzer/protocol/http/HTTP.cc index 14eab65ddc..8b1cf4c415 100644 --- a/src/analyzer/protocol/http/HTTP.cc +++ b/src/analyzer/protocol/http/HTTP.cc @@ -48,7 +48,7 @@ HTTP_Entity::HTTP_Entity(HTTP_Message *arg_message, MIME_Entity* parent_entity, header_length = 0; deliver_body = true; encoding = IDENTITY; - zip = 0; + zip = nullptr; is_partial_content = false; offset = 0; instance_length = -1; // unspecified @@ -67,7 +67,7 @@ void HTTP_Entity::EndOfData() { zip->Done(); delete zip; - zip = 0; + zip = nullptr; encoding = IDENTITY; } @@ -114,7 +114,7 @@ void HTTP_Entity::Deliver(int len, const char* data, bool trailing_CRLF) switch ( chunked_transfer_state ) { case EXPECT_CHUNK_SIZE: ASSERT(trailing_CRLF); - if ( ! atoi_n(len, data, 0, 16, expect_data_length) ) + if ( ! atoi_n(len, data, nullptr, 16, expect_data_length) ) { http_message->Weird("HTTP_bad_chunk_size"); expect_data_length = 0; @@ -365,7 +365,7 @@ void HTTP_Entity::SubmitHeader(mime::MIME_Header* h) if ( ! mime::is_null_data_chunk(vt) ) { int64_t n; - if ( atoi_n(vt.length, vt.data, 0, 10, n) ) + if ( atoi_n(vt.length, vt.data, nullptr, 10, n) ) { content_length = n; @@ -427,8 +427,8 @@ void HTTP_Entity::SubmitHeader(mime::MIME_Header* h) instance_length_str.c_str()); int64_t f, l; - atoi_n(first_byte_pos.size(), first_byte_pos.c_str(), 0, 10, f); - atoi_n(last_byte_pos.size(), last_byte_pos.c_str(), 0, 10, l); + atoi_n(first_byte_pos.size(), first_byte_pos.c_str(), nullptr, 10, f); + atoi_n(last_byte_pos.size(), last_byte_pos.c_str(), nullptr, 10, l); int64_t len = l - f + 1; if ( DEBUG_http ) @@ -439,7 +439,7 @@ void HTTP_Entity::SubmitHeader(mime::MIME_Header* h) if ( instance_length_str != "*" ) { if ( ! atoi_n(instance_length_str.size(), - instance_length_str.c_str(), 0, 10, + instance_length_str.c_str(), nullptr, 10, instance_length) ) instance_length = 0; } @@ -596,9 +596,9 @@ HTTP_Message::HTTP_Message(HTTP_Analyzer* arg_analyzer, content_line = arg_cl; is_orig = arg_is_orig; - current_entity = 0; - top_level = new HTTP_Entity(this, 0, expect_body); - entity_data_buffer = 0; + current_entity = nullptr; + top_level = new HTTP_Entity(this, nullptr, expect_body); + entity_data_buffer = nullptr; BeginEntity(top_level); start_time = network_time; @@ -837,20 +837,20 @@ HTTP_Analyzer::HTTP_Analyzer(Connection* conn) keep_alive = 0; connection_close = 0; - request_message = reply_message = 0; + request_message = reply_message = nullptr; request_state = EXPECT_REQUEST_LINE; reply_state = EXPECT_REPLY_LINE; request_ongoing = 0; - request_method = request_URI = 0; - unescaped_URI = 0; + request_method = request_URI = nullptr; + unescaped_URI = nullptr; reply_ongoing = 0; reply_code = 0; - reply_reason_phrase = 0; + reply_reason_phrase = nullptr; connect_request = false; - pia = 0; + pia = nullptr; upgraded = false; upgrade_connection = false; upgrade_protocol.clear(); @@ -882,10 +882,10 @@ void HTTP_Analyzer::Done() ReplyMade(true, "message interrupted when connection done"); delete request_message; - request_message = 0; + request_message = nullptr; delete reply_message; - reply_message = 0; + reply_message = nullptr; GenStats(); @@ -1061,8 +1061,8 @@ void HTTP_Analyzer::DeliverStream(int len, const u_char* data, bool is_orig) if ( AddChildAnalyzer(pia) ) { - pia->FirstPacket(true, 0); - pia->FirstPacket(false, 0); + pia->FirstPacket(true, nullptr); + pia->FirstPacket(false, nullptr); // This connection has transitioned to no longer // being http and the content line support analyzers @@ -1073,7 +1073,7 @@ void HTTP_Analyzer::DeliverStream(int len, const u_char* data, bool is_orig) else // AddChildAnalyzer() will have deleted PIA. - pia = 0; + pia = nullptr; } break; @@ -1193,7 +1193,7 @@ const char* HTTP_Analyzer::PrefixMatch(const char* line, if ( *prefix ) // It didn't match. - return 0; + return nullptr; return line; } @@ -1201,15 +1201,15 @@ const char* HTTP_Analyzer::PrefixMatch(const char* line, const char* HTTP_Analyzer::PrefixWordMatch(const char* line, const char* end_of_line, const char* prefix) { - if ( (line = PrefixMatch(line, end_of_line, prefix)) == 0 ) - return 0; + if ( (line = PrefixMatch(line, end_of_line, prefix)) == nullptr ) + return nullptr; const char* orig_line = line; line = skip_whitespace(line, end_of_line); if ( line == orig_line ) // Word didn't end at prefix. - return 0; + return nullptr; return line; } @@ -1235,7 +1235,7 @@ static const char* get_HTTP_token(const char* s, const char* e) int HTTP_Analyzer::HTTP_RequestLine(const char* line, const char* end_of_line) { - const char* rest = 0; + const char* rest = nullptr; const char* end_of_method = get_HTTP_token(line, end_of_line); if ( end_of_method == line ) @@ -1439,7 +1439,7 @@ void HTTP_Analyzer::HTTP_Reply() else { Unref(reply_reason_phrase); - reply_reason_phrase = 0; + reply_reason_phrase = nullptr; } } @@ -1459,7 +1459,7 @@ void HTTP_Analyzer::RequestMade(bool interrupted, const char* msg) Unref(unescaped_URI); Unref(request_URI); - request_method = request_URI = unescaped_URI = 0; + request_method = request_URI = unescaped_URI = nullptr; num_request_lines = 0; @@ -1492,7 +1492,7 @@ void HTTP_Analyzer::ReplyMade(bool interrupted, const char* msg) if ( reply_reason_phrase ) { Unref(reply_reason_phrase); - reply_reason_phrase = 0; + reply_reason_phrase = nullptr; } // unanswered requests = 1 because there is no pop after 101. @@ -1531,7 +1531,7 @@ void HTTP_Analyzer::RequestClash(Val* /* clash_val */) const BroString* HTTP_Analyzer::UnansweredRequestMethod() { - return unanswered_requests.empty() ? 0 : unanswered_requests.front()->AsString(); + return unanswered_requests.empty() ? nullptr : unanswered_requests.front()->AsString(); } int HTTP_Analyzer::HTTP_ReplyLine(const char* line, const char* end_of_line) diff --git a/src/analyzer/protocol/icmp/ICMP.cc b/src/analyzer/protocol/icmp/ICMP.cc index 59e8d93909..552f87c947 100644 --- a/src/analyzer/protocol/icmp/ICMP.cc +++ b/src/analyzer/protocol/icmp/ICMP.cc @@ -81,7 +81,7 @@ void ICMP_Analyzer::DeliverPacket(int len, const u_char* data, if ( rule_matcher ) { if ( ! matcher_state.MatcherInitialized(is_orig) ) - matcher_state.InitEndpointMatcher(this, ip, len, is_orig, 0); + matcher_state.InitEndpointMatcher(this, ip, len, is_orig, nullptr); } type = icmpp->icmp_type; @@ -497,7 +497,7 @@ void ICMP_Analyzer::Echo(double t, const struct icmp* icmpp, int len, int caplen, const u_char*& data, const IP_Hdr* ip_hdr) { // For handling all Echo related ICMP messages - EventHandlerPtr f = 0; + EventHandlerPtr f = nullptr; if ( ip_hdr->NextProto() == IPPROTO_ICMPV6 ) f = (icmpp->icmp_type == ICMP6_ECHO_REQUEST) @@ -658,7 +658,7 @@ void ICMP_Analyzer::RouterSolicit(double t, const struct icmp* icmpp, int len, void ICMP_Analyzer::Context4(double t, const struct icmp* icmpp, int len, int caplen, const u_char*& data, const IP_Hdr* ip_hdr) { - EventHandlerPtr f = 0; + EventHandlerPtr f = nullptr; switch ( icmpp->icmp_type ) { @@ -684,7 +684,7 @@ void ICMP_Analyzer::Context4(double t, const struct icmp* icmpp, void ICMP_Analyzer::Context6(double t, const struct icmp* icmpp, int len, int caplen, const u_char*& data, const IP_Hdr* ip_hdr) { - EventHandlerPtr f = 0; + EventHandlerPtr f = nullptr; switch ( icmpp->icmp_type ) { @@ -720,8 +720,8 @@ void ICMP_Analyzer::Context6(double t, const struct icmp* icmpp, VectorVal* ICMP_Analyzer::BuildNDOptionsVal(int caplen, const u_char* data) { - static RecordType* icmp6_nd_option_type = 0; - static RecordType* icmp6_nd_prefix_info_type = 0; + static RecordType* icmp6_nd_option_type = nullptr; + static RecordType* icmp6_nd_prefix_info_type = nullptr; if ( ! icmp6_nd_option_type ) { diff --git a/src/analyzer/protocol/ident/Ident.cc b/src/analyzer/protocol/ident/Ident.cc index 5417492f58..a9c6d5a066 100644 --- a/src/analyzer/protocol/ident/Ident.cc +++ b/src/analyzer/protocol/ident/Ident.cc @@ -52,7 +52,7 @@ void Ident_Analyzer::DeliverStream(int length, const u_char* data, bool is_orig) const char* orig_line = line; const char* end_of_line = line + length; - tcp::TCP_Endpoint* s = 0; + tcp::TCP_Endpoint* s = nullptr; if ( TCP() ) s = is_orig ? TCP()->Orig() : TCP()->Resp(); @@ -194,17 +194,17 @@ const char* Ident_Analyzer::ParsePair(const char* line, const char* end_of_line, line = ParsePort(line, end_of_line, p1); if ( ! line ) { - return 0; + return nullptr; } if ( line >= end_of_line || line[0] != ',' ) - return 0; + return nullptr; ++line; line = ParsePort(line, end_of_line, p2); if ( ! line ) - return 0; + return nullptr; return line; } @@ -216,7 +216,7 @@ const char* Ident_Analyzer::ParsePort(const char* line, const char* end_of_line, line = skip_whitespace(line, end_of_line); if ( ! isdigit(*line) ) - return 0; + return nullptr; const char* l = line; diff --git a/src/analyzer/protocol/irc/IRC.cc b/src/analyzer/protocol/irc/IRC.cc index ff9bb4cb4c..258ae51086 100644 --- a/src/analyzer/protocol/irc/IRC.cc +++ b/src/analyzer/protocol/irc/IRC.cc @@ -277,7 +277,7 @@ void IRC_Analyzer::DeliverStream(int length, const u_char* line, bool orig) if ( parts[i][0] == '@' ) parts[i] = parts[i].substr(1); auto idx = make_intrusive(parts[i].c_str()); - set->Assign(idx.get(), 0); + set->Assign(idx.get(), nullptr); } EnqueueConnEvent(irc_names_info, @@ -468,7 +468,7 @@ void IRC_Analyzer::DeliverStream(int length, const u_char* line, bool orig) for ( unsigned int i = 0; i < parts.size(); ++i ) { auto idx = make_intrusive(parts[i].c_str()); - set->Assign(idx.get(), 0); + set->Assign(idx.get(), nullptr); } EnqueueConnEvent(irc_whois_channel_line, @@ -857,7 +857,7 @@ void IRC_Analyzer::DeliverStream(int length, const u_char* line, bool orig) info->Assign(2, make_intrusive(empty_string.c_str())); // User mode. info->Assign(3, make_intrusive(empty_string.c_str())); - list->Assign(info, 0); + list->Assign(info, nullptr); Unref(info); } @@ -918,7 +918,7 @@ void IRC_Analyzer::DeliverStream(int length, const u_char* line, bool orig) info->Assign(2, make_intrusive(empty_string.c_str())); // User mode: info->Assign(3, make_intrusive(mode.c_str())); - list->Assign(info.get(), 0); + list->Assign(info.get(), nullptr); } EnqueueConnEvent(irc_join_message, @@ -957,7 +957,7 @@ void IRC_Analyzer::DeliverStream(int length, const u_char* line, bool orig) for ( unsigned int i = 0; i < channelList.size(); ++i ) { auto idx = make_intrusive(channelList[i].c_str()); - set->Assign(idx.get(), 0); + set->Assign(idx.get(), nullptr); } EnqueueConnEvent(irc_part_message, diff --git a/src/analyzer/protocol/login/Login.cc b/src/analyzer/protocol/login/Login.cc index 39767ca420..d3dfee53f9 100644 --- a/src/analyzer/protocol/login/Login.cc +++ b/src/analyzer/protocol/login/Login.cc @@ -16,7 +16,7 @@ using namespace analyzer::login; -static RE_Matcher* re_skip_authentication = 0; +static RE_Matcher* re_skip_authentication = nullptr; static RE_Matcher* re_direct_login_prompts; static RE_Matcher* re_login_prompts; static RE_Matcher* re_login_non_failure_msgs; @@ -39,7 +39,7 @@ Login_Analyzer::Login_Analyzer(const char* name, Connection* conn) user_text_first = 0; user_text_last = MAX_USER_TEXT - 1; num_user_text = 0; - client_name = username = 0; + client_name = username = nullptr; saw_ploy = is_VMS = false; if ( ! re_skip_authentication ) @@ -214,7 +214,7 @@ void Login_Analyzer::AuthenticationDialog(bool orig, char* line) // respect to it (see below). login_prompt_line != failure_line); - const char* next_prompt = 0; + const char* next_prompt = nullptr; while ( (*prompt != '\0' && (next_prompt = IsLoginPrompt(prompt + 1))) || multi_line_prompt ) @@ -507,7 +507,7 @@ const char* Login_Analyzer::IsLoginPrompt(const char* line) const int prompt_match = re_login_prompts->MatchAnywhere(line); if ( ! prompt_match || IsFailureMsg(line) ) // IRIX can report "login: ERROR: Login incorrect" - return 0; + return nullptr; return &line[prompt_match]; } @@ -565,7 +565,7 @@ char* Login_Analyzer::PeekUserText() { reporter->AnalyzerError(this, "underflow in Login_Analyzer::PeekUserText()"); - return 0; + return nullptr; } return user_text[user_text_first]; @@ -576,7 +576,7 @@ char* Login_Analyzer::PopUserText() char* s = PeekUserText(); if ( ! s ) - return 0; + return nullptr; if ( ++user_text_first == MAX_USER_TEXT ) user_text_first = 0; diff --git a/src/analyzer/protocol/login/NVT.cc b/src/analyzer/protocol/login/NVT.cc index 89295e1ac2..096adca591 100644 --- a/src/analyzer/protocol/login/NVT.cc +++ b/src/analyzer/protocol/login/NVT.cc @@ -320,7 +320,7 @@ char* TelnetEnvironmentOption::ExtractEnv(u_char*& data, int& len, int& code) if ( code != ENVIRON_VAR && code != ENVIRON_VAL && code != ENVIRON_USERVAR ) - return 0; + return nullptr; // Move past code. --len; @@ -338,7 +338,7 @@ char* TelnetEnvironmentOption::ExtractEnv(u_char*& data, int& len, int& code) { ++d; // move past ESC if ( d >= data_end ) - return 0; + return nullptr; break; } } @@ -400,7 +400,7 @@ TelnetOption* NVT_Analyzer::FindOption(unsigned int code) if ( options[i]->Code() == code ) return options[i]; - TelnetOption* opt = 0; + TelnetOption* opt = nullptr; if ( i < NUM_TELNET_OPTIONS ) { // Maybe we haven't created this option yet. switch ( code ) { diff --git a/src/analyzer/protocol/login/Plugin.cc b/src/analyzer/protocol/login/Plugin.cc index aeedd5c04d..27457b04d7 100644 --- a/src/analyzer/protocol/login/Plugin.cc +++ b/src/analyzer/protocol/login/Plugin.cc @@ -17,10 +17,10 @@ public: AddComponent(new ::analyzer::Component("Telnet", ::analyzer::login::Telnet_Analyzer::Instantiate)); AddComponent(new ::analyzer::Component("Rsh", ::analyzer::login::Rsh_Analyzer::Instantiate)); AddComponent(new ::analyzer::Component("Rlogin", ::analyzer::login::Rlogin_Analyzer::Instantiate)); - AddComponent(new ::analyzer::Component("NVT", 0)); - AddComponent(new ::analyzer::Component("Login", 0)); - AddComponent(new ::analyzer::Component("Contents_Rsh", 0)); - AddComponent(new ::analyzer::Component("Contents_Rlogin", 0)); + AddComponent(new ::analyzer::Component("NVT", nullptr)); + AddComponent(new ::analyzer::Component("Login", nullptr)); + AddComponent(new ::analyzer::Component("Contents_Rsh", nullptr)); + AddComponent(new ::analyzer::Component("Contents_Rlogin", nullptr)); plugin::Configuration config; config.name = "Zeek::Login"; diff --git a/src/analyzer/protocol/login/Rlogin.cc b/src/analyzer/protocol/login/Rlogin.cc index e041d757c9..244deb9cba 100644 --- a/src/analyzer/protocol/login/Rlogin.cc +++ b/src/analyzer/protocol/login/Rlogin.cc @@ -16,7 +16,7 @@ Contents_Rlogin_Analyzer::Contents_Rlogin_Analyzer(Connection* conn, bool orig, { num_bytes_to_scan = 0; analyzer = arg_analyzer; - peer = 0; + peer = nullptr; if ( orig ) state = save_state = RLOGIN_FIRST_NULL; diff --git a/src/analyzer/protocol/mime/MIME.cc b/src/analyzer/protocol/mime/MIME.cc index ea689733de..d644f00bb0 100644 --- a/src/analyzer/protocol/mime/MIME.cc +++ b/src/analyzer/protocol/mime/MIME.cc @@ -21,7 +21,7 @@ namespace analyzer { namespace mime { -static const data_chunk_t null_data_chunk = { 0, 0 }; +static const data_chunk_t null_data_chunk = { 0, nullptr }; int mime_header_only = 0; int mime_decode_data = 1; @@ -65,14 +65,14 @@ enum MIME_BOUNDARY_DELIMITER { static const char* MIMEHeaderName[] = { "content-type", "content-transfer-encoding", - 0, + nullptr, }; static const char* MIMEContentTypeName[] = { "MULTIPART", "MESSAGE", "TEXT", - 0, + nullptr, }; static const char* MIMEContentSubtypeName[] = { @@ -86,7 +86,7 @@ static const char* MIMEContentSubtypeName[] = { "PLAIN", // for text - 0, // other + nullptr, // other }; static const char* MIMEContentEncodingName[] = { @@ -95,12 +95,12 @@ static const char* MIMEContentEncodingName[] = { "BINARY", "QUOTED-PRINTABLE", "BASE64", - 0, + nullptr, }; bool is_null_data_chunk(data_chunk_t b) { - return b.data == 0; + return b.data == nullptr; } bool is_lws(char ch) @@ -437,7 +437,7 @@ using namespace analyzer::mime; MIME_Multiline::MIME_Multiline() { - line = 0; + line = nullptr; } MIME_Multiline::~MIME_Multiline() @@ -454,7 +454,7 @@ void MIME_Multiline::append(int len, const char* data) BroString* MIME_Multiline::get_concatenated_line() { if ( buffer.empty() ) - return 0; + return nullptr; delete line; line = concatenate(buffer); @@ -546,7 +546,7 @@ void MIME_Entity::init() in_header = 1; end_of_data = 0; - current_header_line = 0; + current_header_line = nullptr; current_field_type = MIME_FIELD_OTHER; need_to_parse_parameters = 0; @@ -554,22 +554,22 @@ void MIME_Entity::init() content_type_str = new StringVal("TEXT"); content_subtype_str = new StringVal("PLAIN"); - content_encoding_str = 0; - multipart_boundary = 0; + content_encoding_str = nullptr; + multipart_boundary = nullptr; content_type = CONTENT_TYPE_TEXT; content_subtype = CONTENT_SUBTYPE_PLAIN; content_encoding = CONTENT_ENCODING_OTHER; - parent = 0; - current_child_entity = 0; + parent = nullptr; + current_child_entity = nullptr; - base64_decoder = 0; + base64_decoder = nullptr; data_buf_length = 0; - data_buf_data = 0; + data_buf_data = nullptr; data_buf_offset = -1; - message = 0; + message = nullptr; delay_adding_implicit_CRLF = false; want_all_headers = false; } @@ -577,7 +577,7 @@ void MIME_Entity::init() MIME_Entity::~MIME_Entity() { if ( ! end_of_data ) - reporter->AnalyzerError(message ? message->GetAnalyzer() : 0, + reporter->AnalyzerError(message ? message->GetAnalyzer() : nullptr, "missing MIME_Entity::EndOfData() before ~MIME_Entity"); delete current_header_line; @@ -653,7 +653,7 @@ void MIME_Entity::EndOfData() else { - if ( current_child_entity != 0 ) + if ( current_child_entity != nullptr ) { if ( content_type == CONTENT_TYPE_MULTIPART ) IllegalFormat("multipart closing boundary delimiter missing"); @@ -675,13 +675,13 @@ void MIME_Entity::NewDataLine(int len, const char* data, bool trailing_CRLF) { switch ( CheckBoundaryDelimiter(len, data) ) { case MULTIPART_BOUNDARY: - if ( current_child_entity != 0 ) + if ( current_child_entity != nullptr ) EndChildEntity(); BeginChildEntity(); return; case MULTIPART_CLOSING_BOUNDARY: - if ( current_child_entity != 0 ) + if ( current_child_entity != nullptr ) EndChildEntity(); EndOfData(); return; @@ -695,7 +695,7 @@ void MIME_Entity::NewDataLine(int len, const char* data, bool trailing_CRLF) // binary encoding, and thus do not need to decode // before passing the data to child. - if ( current_child_entity != 0 ) + if ( current_child_entity != nullptr ) // Data before the first or after the last // boundary delimiter are ignored current_child_entity->Deliver(len, data, trailing_CRLF); @@ -722,7 +722,7 @@ void MIME_Entity::NewHeader(int len, const char* data) void MIME_Entity::ContHeader(int len, const char* data) { - if ( current_header_line == 0 ) + if ( current_header_line == nullptr ) { IllegalFormat("first header line starts with linear whitespace"); @@ -737,11 +737,11 @@ void MIME_Entity::ContHeader(int len, const char* data) void MIME_Entity::FinishHeader() { - if ( current_header_line == 0 ) + if ( current_header_line == nullptr ) return; MIME_Header* h = new MIME_Header(current_header_line); - current_header_line = 0; + current_header_line = nullptr; if ( ! is_null_data_chunk(h->get_name()) ) { @@ -762,7 +762,7 @@ int MIME_Entity::LookupMIMEHeaderName(data_chunk_t name) // A linear lookup should be fine for now. // header names are case-insensitive (RFC 822, 2822, 2045). - for ( int i = 0; MIMEHeaderName[i] != 0; ++i ) + for ( int i = 0; MIMEHeaderName[i] != nullptr; ++i ) if ( istrequal(name, MIMEHeaderName[i]) ) return i; return -1; @@ -770,7 +770,7 @@ int MIME_Entity::LookupMIMEHeaderName(data_chunk_t name) void MIME_Entity::ParseMIMEHeader(MIME_Header* h) { - if ( h == 0 ) + if ( h == nullptr ) return; current_field_type = LookupMIMEHeaderName(h->get_name()); @@ -884,7 +884,7 @@ bool MIME_Entity::ParseFieldParameters(int len, const char* data) data += offset; len -= offset; - BroString* val = 0; + BroString* val = nullptr; if ( current_field_type == MIME_CONTENT_TYPE && content_type == CONTENT_TYPE_MULTIPART && @@ -1172,13 +1172,13 @@ void MIME_Entity::FinishDecodeBase64() } delete base64_decoder; - base64_decoder = 0; + base64_decoder = nullptr; } bool MIME_Entity::GetDataBuffer() { int ret = message->RequestBuffer(&data_buf_length, &data_buf_data); - if ( ! ret || data_buf_length == 0 || data_buf_data == 0 ) + if ( ! ret || data_buf_length == 0 || data_buf_data == nullptr ) { // reporter->InternalError("cannot get data buffer from MIME_Message", ""); return false; @@ -1250,18 +1250,18 @@ void MIME_Entity::SubmitAllHeaders() void MIME_Entity::BeginChildEntity() { - ASSERT(current_child_entity == 0); + ASSERT(current_child_entity == nullptr); current_child_entity = NewChildEntity(); message->BeginEntity(current_child_entity); } void MIME_Entity::EndChildEntity() { - ASSERT(current_child_entity != 0); + ASSERT(current_child_entity != nullptr); current_child_entity->EndOfData(); delete current_child_entity; - current_child_entity = 0; + current_child_entity = nullptr; } void MIME_Entity::IllegalFormat(const char* explanation) @@ -1349,7 +1349,7 @@ MIME_Mail::MIME_Mail(analyzer::Analyzer* mail_analyzer, bool orig, int buf_size) content_hash_length = 0; - top_level = new MIME_Entity(this, 0); // to be changed to MIME_Mail + top_level = new MIME_Entity(this, nullptr); // to be changed to MIME_Mail BeginEntity(top_level); } diff --git a/src/analyzer/protocol/mime/MIME.h b/src/analyzer/protocol/mime/MIME.h index f7026bf758..63e8e6b56d 100644 --- a/src/analyzer/protocol/mime/MIME.h +++ b/src/analyzer/protocol/mime/MIME.h @@ -188,7 +188,7 @@ public: // Cannot initialize top_level entity because we do // not know its type yet (MIME_Entity / MIME_Mail / // etc.). - top_level = 0; + top_level = nullptr; finished = false; analyzer = arg_analyzer; } diff --git a/src/analyzer/protocol/ncp/NCP.cc b/src/analyzer/protocol/ncp/NCP.cc index 03580d2abb..08ff6d5ac3 100644 --- a/src/analyzer/protocol/ncp/NCP.cc +++ b/src/analyzer/protocol/ncp/NCP.cc @@ -83,7 +83,7 @@ void NCP_Session::DeliverFrame(const binpac::NCP::ncp_frame* frame) FrameBuffer::FrameBuffer(size_t header_length) { hdr_len = header_length; - msg_buf = 0; + msg_buf = nullptr; buf_len = 0; Reset(); } diff --git a/src/analyzer/protocol/ncp/Plugin.cc b/src/analyzer/protocol/ncp/Plugin.cc index 9f17881f1b..b76fcbf748 100644 --- a/src/analyzer/protocol/ncp/Plugin.cc +++ b/src/analyzer/protocol/ncp/Plugin.cc @@ -12,7 +12,7 @@ public: plugin::Configuration Configure() override { AddComponent(new ::analyzer::Component("NCP", ::analyzer::ncp::NCP_Analyzer::Instantiate)); - AddComponent(new ::analyzer::Component("Contents_NCP", 0)); + AddComponent(new ::analyzer::Component("Contents_NCP", nullptr)); plugin::Configuration config; config.name = "Zeek::NCP"; diff --git a/src/analyzer/protocol/netbios/NetbiosSSN.cc b/src/analyzer/protocol/netbios/NetbiosSSN.cc index 31b662d4e6..3af2569738 100644 --- a/src/analyzer/protocol/netbios/NetbiosSSN.cc +++ b/src/analyzer/protocol/netbios/NetbiosSSN.cc @@ -214,7 +214,7 @@ int NetbiosSSN_Interpreter::ConvertName(const u_char* name, int name_len, { // Taken from tcpdump's smbutil.c. - xname = 0; + xname = nullptr; if ( name_len < 1 ) return 0; @@ -340,7 +340,7 @@ Contents_NetbiosSSN::Contents_NetbiosSSN(Connection* conn, bool orig, { interp = arg_interp; type = flags = msg_size = 0; - msg_buf = 0; + msg_buf = nullptr; buf_n = buf_len = msg_size = 0; state = NETBIOS_SSN_TYPE; } @@ -455,7 +455,7 @@ NetbiosSSN_Analyzer::NetbiosSSN_Analyzer(Connection* conn) { //smb_session = new SMB_Session(this); interp = new NetbiosSSN_Interpreter(this); - orig_netbios = resp_netbios = 0; + orig_netbios = resp_netbios = nullptr; did_session_done = 0; if ( Conn()->ConnTransport() == TRANSPORT_TCP ) diff --git a/src/analyzer/protocol/netbios/Plugin.cc b/src/analyzer/protocol/netbios/Plugin.cc index dde55af51f..47db030464 100644 --- a/src/analyzer/protocol/netbios/Plugin.cc +++ b/src/analyzer/protocol/netbios/Plugin.cc @@ -12,7 +12,7 @@ public: plugin::Configuration Configure() override { AddComponent(new ::analyzer::Component("NetbiosSSN", ::analyzer::netbios_ssn::NetbiosSSN_Analyzer::Instantiate)); - AddComponent(new ::analyzer::Component("Contents_NetbiosSSN", 0)); + AddComponent(new ::analyzer::Component("Contents_NetbiosSSN", nullptr)); plugin::Configuration config; config.name = "Zeek::NetBIOS"; diff --git a/src/analyzer/protocol/pia/PIA.cc b/src/analyzer/protocol/pia/PIA.cc index f57771e708..5845f7d540 100644 --- a/src/analyzer/protocol/pia/PIA.cc +++ b/src/analyzer/protocol/pia/PIA.cc @@ -22,7 +22,7 @@ PIA::~PIA() void PIA::ClearBuffer(Buffer* buffer) { - DataBlock* next = 0; + DataBlock* next = nullptr; for ( DataBlock* b = buffer->head; b; b = next ) { next = b->next; @@ -31,14 +31,14 @@ void PIA::ClearBuffer(Buffer* buffer) delete b; } - buffer->head = buffer->tail = 0; + buffer->head = buffer->tail = nullptr; buffer->size = 0; } void PIA::AddToBuffer(Buffer* buffer, uint64_t seq, int len, const u_char* data, bool is_orig, const IP_Hdr* ip) { - u_char* tmp = 0; + u_char* tmp = nullptr; if ( data ) { @@ -47,12 +47,12 @@ void PIA::AddToBuffer(Buffer* buffer, uint64_t seq, int len, const u_char* data, } DataBlock* b = new DataBlock; - b->ip = ip ? ip->Copy() : 0; + b->ip = ip ? ip->Copy() : nullptr; b->data = tmp; b->is_orig = is_orig; b->len = len; b->seq = seq; - b->next = 0; + b->next = nullptr; if ( buffer->tail ) { @@ -117,14 +117,14 @@ void PIA::PIA_DeliverPacket(int len, const u_char* data, bool is_orig, uint64_t pkt_buffer.state = new_state; - current_packet.data = 0; + current_packet.data = nullptr; } void PIA::Match(Rule::PatternType type, const u_char* data, int len, bool is_orig, bool bol, bool eol, bool clear_state) { if ( ! MatcherInitialized(is_orig) ) - InitEndpointMatcher(AsAnalyzer(), 0, 0, is_orig, this); + InitEndpointMatcher(AsAnalyzer(), nullptr, 0, is_orig, this); RuleMatcherState::Match(type, data, len, is_orig, bol, eol, clear_state); } @@ -207,9 +207,9 @@ void PIA_TCP::Init() void PIA_TCP::FirstPacket(bool is_orig, const IP_Hdr* ip) { static char dummy_packet[sizeof(struct ip) + sizeof(struct tcphdr)]; - static struct ip* ip4 = 0; - static struct tcphdr* tcp4 = 0; - static IP_Hdr* ip4_hdr = 0; + static struct ip* ip4 = nullptr; + static struct tcphdr* tcp4 = nullptr; + static IP_Hdr* ip4_hdr = nullptr; DBG_LOG(DBG_ANALYZER, "PIA_TCP[%d] FirstPacket(%s)", GetID(), (is_orig ? "T" : "F")); @@ -277,7 +277,7 @@ void PIA_TCP::DeliverStream(int len, const u_char* data, bool is_orig) SKIPPING : MATCHING_ONLY; } - DoMatch(data, len, is_orig, false, false, false, 0); + DoMatch(data, len, is_orig, false, false, false, nullptr); stream_buffer.state = new_state; } @@ -288,7 +288,7 @@ void PIA_TCP::Undelivered(uint64_t seq, int len, bool is_orig) if ( stream_buffer.state == BUFFERING ) // We use data=nil to mark an undelivered. - AddToBuffer(&stream_buffer, seq, len, 0, is_orig); + AddToBuffer(&stream_buffer, seq, len, nullptr, is_orig); // No check for buffer overrun here. I think that's ok. } diff --git a/src/analyzer/protocol/pia/PIA.h b/src/analyzer/protocol/pia/PIA.h index 467d353464..575cb89571 100644 --- a/src/analyzer/protocol/pia/PIA.h +++ b/src/analyzer/protocol/pia/PIA.h @@ -25,7 +25,7 @@ public: // Called when PIA wants to put an Analyzer in charge. rule is the // signature that triggered the activitation, if any. virtual void ActivateAnalyzer(analyzer::Tag tag, - const Rule* rule = 0) = 0; + const Rule* rule = nullptr) = 0; // Called when PIA wants to remove an Analyzer. virtual void DeactivateAnalyzer(analyzer::Tag tag) = 0; @@ -58,7 +58,7 @@ protected: }; struct Buffer { - Buffer() { head = tail = 0; size = 0; state = INIT; } + Buffer() { head = tail = nullptr; size = 0; state = INIT; } DataBlock* head; DataBlock* tail; @@ -67,15 +67,15 @@ protected: }; void AddToBuffer(Buffer* buffer, uint64_t seq, int len, - const u_char* data, bool is_orig, const IP_Hdr* ip = 0); + const u_char* data, bool is_orig, const IP_Hdr* ip = nullptr); void AddToBuffer(Buffer* buffer, int len, - const u_char* data, bool is_orig, const IP_Hdr* ip = 0); + const u_char* data, bool is_orig, const IP_Hdr* ip = nullptr); void ClearBuffer(Buffer* buffer); DataBlock* CurrentPacket() { return ¤t_packet; } void DoMatch(const u_char* data, int len, bool is_orig, bool bol, - bool eol, bool clear_state, const IP_Hdr* ip = 0); + bool eol, bool clear_state, const IP_Hdr* ip = nullptr); void SetConn(Connection* c) { conn = c; } @@ -161,7 +161,7 @@ protected: void Undelivered(uint64_t seq, int len, bool is_orig) override; void ActivateAnalyzer(analyzer::Tag tag, - const Rule* rule = 0) override; + const Rule* rule = nullptr) override; void DeactivateAnalyzer(analyzer::Tag tag) override; private: diff --git a/src/analyzer/protocol/pop3/POP3.cc b/src/analyzer/protocol/pop3/POP3.cc index c5e2d9bb1f..174d11b826 100644 --- a/src/analyzer/protocol/pop3/POP3.cc +++ b/src/analyzer/protocol/pop3/POP3.cc @@ -43,7 +43,7 @@ POP3_Analyzer::POP3_Analyzer(Connection* conn) lastRequiredCommand = 0; authLines = 0; - mail = 0; + mail = nullptr; cl_orig = new tcp::ContentLine_Analyzer(conn, true); AddSupportAnalyzer(cl_orig); @@ -136,7 +136,7 @@ void POP3_Analyzer::ProcessRequest(int length, const char* line) ++authLines; BroString encoded(line); - BroString* decoded = decode_base64(&encoded, 0, Conn()); + BroString* decoded = decode_base64(&encoded, nullptr, Conn()); if ( ! decoded ) { @@ -854,7 +854,7 @@ void POP3_Analyzer::EndData() { mail->Done(); delete mail; - mail = 0; + mail = nullptr; } } diff --git a/src/analyzer/protocol/pop3/POP3.h b/src/analyzer/protocol/pop3/POP3.h index 1af2e4226c..1c92e6005b 100644 --- a/src/analyzer/protocol/pop3/POP3.h +++ b/src/analyzer/protocol/pop3/POP3.h @@ -103,7 +103,7 @@ protected: int ParseCmd(string cmd); void AuthSuccessfull(); void POP3Event(EventHandlerPtr event, bool is_orig, - const char* arg1 = 0, const char* arg2 = 0); + const char* arg1 = nullptr, const char* arg2 = nullptr); mime::MIME_Mail* mail; list cmds; diff --git a/src/analyzer/protocol/rdp/RDP.cc b/src/analyzer/protocol/rdp/RDP.cc index 7deaf6a63f..6b73bcfb1f 100644 --- a/src/analyzer/protocol/rdp/RDP.cc +++ b/src/analyzer/protocol/rdp/RDP.cc @@ -12,7 +12,7 @@ RDP_Analyzer::RDP_Analyzer(Connection* c) interp = new binpac::RDP::RDP_Conn(this); had_gap = false; - pia = 0; + pia = nullptr; } RDP_Analyzer::~RDP_Analyzer() @@ -66,8 +66,8 @@ void RDP_Analyzer::DeliverStream(int len, const u_char* data, bool orig) return; } - pia->FirstPacket(true, 0); - pia->FirstPacket(false, 0); + pia->FirstPacket(true, nullptr); + pia->FirstPacket(false, nullptr); } ForwardStream(len, data, orig); diff --git a/src/analyzer/protocol/rpc/MOUNT.cc b/src/analyzer/protocol/rpc/MOUNT.cc index f15a9f154a..96fb4df1d2 100644 --- a/src/analyzer/protocol/rpc/MOUNT.cc +++ b/src/analyzer/protocol/rpc/MOUNT.cc @@ -22,7 +22,7 @@ bool MOUNT_Interp::RPC_BuildCall(RPC_CallInfo* c, const u_char*& buf, int& n) uint32_t proc = c->Proc(); // The call arguments, depends on the call type obviously ... - Val *callarg = 0; + Val *callarg = nullptr; switch ( proc ) { case BifEnum::MOUNT3::PROC_NULL: @@ -41,7 +41,7 @@ bool MOUNT_Interp::RPC_BuildCall(RPC_CallInfo* c, const u_char*& buf, int& n) break; default: - callarg = 0; + callarg = nullptr; if ( proc < BifEnum::MOUNT3::PROC_END_OF_PROCS ) { // We know the procedure but haven't implemented it. @@ -65,7 +65,7 @@ bool MOUNT_Interp::RPC_BuildCall(RPC_CallInfo* c, const u_char*& buf, int& n) // RecordVal was allocated but we failed to fill it). So we // Unref() the call arguments, and we are fine. Unref(callarg); - callarg = 0; + callarg = nullptr; return false; } @@ -78,8 +78,8 @@ bool MOUNT_Interp::RPC_BuildReply(RPC_CallInfo* c, BifEnum::rpc_status rpc_statu const u_char*& buf, int& n, double start_time, double last_time, int reply_len) { - EventHandlerPtr event = 0; - Val* reply = 0; + EventHandlerPtr event = nullptr; + Val* reply = nullptr; BifEnum::MOUNT3::status_t mount_status = BifEnum::MOUNT3::MNT3_OK; bool rpc_success = ( rpc_status == BifEnum::RPC_SUCCESS ); @@ -104,7 +104,7 @@ bool MOUNT_Interp::RPC_BuildReply(RPC_CallInfo* c, BifEnum::rpc_status rpc_statu // We set the buffer to NULL, the function that extract the // reply from the data stream will then return empty records. // - buf = NULL; + buf = nullptr; n = 0; } @@ -119,14 +119,14 @@ bool MOUNT_Interp::RPC_BuildReply(RPC_CallInfo* c, BifEnum::rpc_status rpc_statu break; case BifEnum::MOUNT3::PROC_UMNT: - reply = 0; + reply = nullptr; n = 0; mount_status = BifEnum::MOUNT3::MNT3_OK; event = mount_proc_umnt; break; case BifEnum::MOUNT3::PROC_UMNT_ALL: - reply = 0; + reply = nullptr; n = 0; mount_status = BifEnum::MOUNT3::MNT3_OK; event = mount_proc_umnt; @@ -151,7 +151,7 @@ bool MOUNT_Interp::RPC_BuildReply(RPC_CallInfo* c, BifEnum::rpc_status rpc_statu // There was a parse error. We have to unref the reply. (see // also comments in RPC_BuildCall. Unref(reply); - reply = 0; + reply = nullptr; return false; } @@ -230,7 +230,7 @@ StringVal* MOUNT_Interp::mount3_fh(const u_char*& buf, int& n) const u_char* fh = extract_XDR_opaque(buf, n, fh_n, 64); if ( ! fh ) - return 0; + return nullptr; return new StringVal(new BroString(fh, fh_n, false)); } @@ -241,7 +241,7 @@ StringVal* MOUNT_Interp::mount3_filename(const u_char*& buf, int& n) const u_char* name = extract_XDR_opaque(buf, n, name_len); if ( ! name ) - return 0; + return nullptr; return new StringVal(new BroString(name, name_len, false)); } @@ -288,8 +288,8 @@ RecordVal* MOUNT_Interp::mount3_mnt_reply(const u_char*& buf, int& n, } else { - rep->Assign(0, 0); - rep->Assign(1, 0); + rep->Assign(0, nullptr); + rep->Assign(1, nullptr); } return rep; @@ -298,7 +298,7 @@ RecordVal* MOUNT_Interp::mount3_mnt_reply(const u_char*& buf, int& n, MOUNT_Analyzer::MOUNT_Analyzer(Connection* conn) : RPC_Analyzer("MOUNT", conn, new MOUNT_Interp(this)) { - orig_rpc = resp_rpc = 0; + orig_rpc = resp_rpc = nullptr; } void MOUNT_Analyzer::Init() diff --git a/src/analyzer/protocol/rpc/NFS.cc b/src/analyzer/protocol/rpc/NFS.cc index bb76727705..b709bee680 100644 --- a/src/analyzer/protocol/rpc/NFS.cc +++ b/src/analyzer/protocol/rpc/NFS.cc @@ -22,7 +22,7 @@ bool NFS_Interp::RPC_BuildCall(RPC_CallInfo* c, const u_char*& buf, int& n) uint32_t proc = c->Proc(); // The call arguments, depends on the call type obviously ... - Val *callarg = 0; + Val *callarg = nullptr; switch ( proc ) { case BifEnum::NFS3::PROC_NULL: @@ -95,7 +95,7 @@ bool NFS_Interp::RPC_BuildCall(RPC_CallInfo* c, const u_char*& buf, int& n) break; default: - callarg = 0; + callarg = nullptr; if ( proc < BifEnum::NFS3::PROC_END_OF_PROCS ) { // We know the procedure but haven't implemented it. @@ -119,7 +119,7 @@ bool NFS_Interp::RPC_BuildCall(RPC_CallInfo* c, const u_char*& buf, int& n) // RecordVal was allocated but we failed to fill it). So we // Unref() the call arguments, and we are fine. Unref(callarg); - callarg = 0; + callarg = nullptr; return false; } @@ -132,8 +132,8 @@ bool NFS_Interp::RPC_BuildReply(RPC_CallInfo* c, BifEnum::rpc_status rpc_status, const u_char*& buf, int& n, double start_time, double last_time, int reply_len) { - EventHandlerPtr event = 0; - Val *reply = 0; + EventHandlerPtr event = nullptr; + Val *reply = nullptr; BifEnum::NFS3::status_t nfs_status = BifEnum::NFS3::NFS3ERR_OK; bool rpc_success = ( rpc_status == BifEnum::RPC_SUCCESS ); @@ -158,7 +158,7 @@ bool NFS_Interp::RPC_BuildReply(RPC_CallInfo* c, BifEnum::rpc_status rpc_status, // We set the buffer to NULL, the function that extract the // reply from the data stream will then return empty records. // - buf = NULL; + buf = nullptr; n = 0; } @@ -263,7 +263,7 @@ bool NFS_Interp::RPC_BuildReply(RPC_CallInfo* c, BifEnum::rpc_status rpc_status, // There was a parse error. We have to unref the reply. (see // also comments in RPC_BuildCall. Unref(reply); - reply = 0; + reply = nullptr; return false; } @@ -303,10 +303,10 @@ StringVal* NFS_Interp::nfs3_file_data(const u_char*& buf, int& n, uint64_t offse // check whether we have to deliver data to the event if ( ! BifConst::NFS3::return_data ) - return 0; + return nullptr; if ( BifConst::NFS3::return_data_first_only && offset != 0 ) - return 0; + return nullptr; // Ok, so we want to return some data data_n = min(data_n, size); @@ -315,7 +315,7 @@ StringVal* NFS_Interp::nfs3_file_data(const u_char*& buf, int& n, uint64_t offse if ( data && data_n > 0 ) return new StringVal(new BroString(data, data_n, false)); - return 0; + return nullptr; } zeek::Args NFS_Interp::event_common_vl(RPC_CallInfo *c, BifEnum::rpc_status rpc_status, @@ -358,7 +358,7 @@ StringVal* NFS_Interp::nfs3_fh(const u_char*& buf, int& n) const u_char* fh = extract_XDR_opaque(buf, n, fh_n, 64); if ( ! fh ) - return 0; + return nullptr; return new StringVal(new BroString(fh, fh_n, false)); } @@ -368,22 +368,22 @@ RecordVal* NFS_Interp::nfs3_sattr(const u_char*& buf, int& n) { RecordVal* attrs = new RecordVal(BifType::Record::NFS3::sattr_t); - attrs->Assign(0, 0); // mode + attrs->Assign(0, nullptr); // mode int mode_set_it = extract_XDR_uint32(buf, n); if ( mode_set_it ) attrs->Assign(0, ExtractUint32(buf, n)); // mode - attrs->Assign(1, 0); // uid + attrs->Assign(1, nullptr); // uid int uid_set_it = extract_XDR_uint32(buf, n); if ( uid_set_it ) attrs->Assign(1, ExtractUint32(buf, n)); // uid - attrs->Assign(2, 0); // gid + attrs->Assign(2, nullptr); // gid int gid_set_it = extract_XDR_uint32(buf, n); if ( gid_set_it ) attrs->Assign(2, ExtractUint32(buf, n)); // gid - attrs->Assign(3, 0); // size + attrs->Assign(3, nullptr); // size int size_set_it = extract_XDR_uint32(buf, n); if ( size_set_it ) attrs->Assign(3, ExtractTime(buf, n)); // size @@ -406,8 +406,8 @@ RecordVal* NFS_Interp::nfs3_sattr_reply(const u_char*& buf, int& n, BifEnum::NFS } else { - rep->Assign(1, 0); - rep->Assign(2, 0); + rep->Assign(1, nullptr); + rep->Assign(2, nullptr); } return rep; @@ -464,7 +464,7 @@ StringVal *NFS_Interp::nfs3_filename(const u_char*& buf, int& n) const u_char* name = extract_XDR_opaque(buf, n, name_len); if ( ! name ) - return 0; + return nullptr; return new StringVal(new BroString(name, name_len, false)); } @@ -508,7 +508,7 @@ RecordVal* NFS_Interp::nfs3_post_op_attr(const u_char*& buf, int& n) if ( have_attrs ) return nfs3_fattr(buf, n); - return 0; + return nullptr; } StringVal* NFS_Interp::nfs3_post_op_fh(const u_char*& buf, int& n) @@ -518,7 +518,7 @@ StringVal* NFS_Interp::nfs3_post_op_fh(const u_char*& buf, int& n) if ( have_fh ) return nfs3_fh(buf, n); - return 0; + return nullptr; } RecordVal* NFS_Interp::nfs3_pre_op_attr(const u_char*& buf, int& n) @@ -527,7 +527,7 @@ RecordVal* NFS_Interp::nfs3_pre_op_attr(const u_char*& buf, int& n) if ( have_attrs ) return nfs3_wcc_attr(buf, n); - return 0; + return nullptr; } EnumVal *NFS_Interp::nfs3_stable_how(const u_char*& buf, int& n) @@ -548,8 +548,8 @@ RecordVal* NFS_Interp::nfs3_lookup_reply(const u_char*& buf, int& n, BifEnum::NF } else { - rep->Assign(0, 0); - rep->Assign(1, 0); + rep->Assign(0, nullptr); + rep->Assign(1, nullptr); rep->Assign(2, nfs3_post_op_attr(buf, n)); } return rep; @@ -710,8 +710,8 @@ RecordVal* NFS_Interp::nfs3_newobj_reply(const u_char*& buf, int& n, BifEnum::NF } else { - rep->Assign(0, 0); - rep->Assign(1, 0); + rep->Assign(0, nullptr); + rep->Assign(1, nullptr); rep->Assign(2, nfs3_pre_op_attr(buf, n)); rep->Assign(3, nfs3_post_op_attr(buf, n)); } @@ -833,7 +833,7 @@ Val* NFS_Interp::ExtractBool(const u_char*& buf, int& n) NFS_Analyzer::NFS_Analyzer(Connection* conn) : RPC_Analyzer("NFS", conn, new NFS_Interp(this)) { - orig_rpc = resp_rpc = 0; + orig_rpc = resp_rpc = nullptr; } void NFS_Analyzer::Init() diff --git a/src/analyzer/protocol/rpc/Plugin.cc b/src/analyzer/protocol/rpc/Plugin.cc index da9b5f0299..6e284c9dbf 100644 --- a/src/analyzer/protocol/rpc/Plugin.cc +++ b/src/analyzer/protocol/rpc/Plugin.cc @@ -17,8 +17,8 @@ public: AddComponent(new ::analyzer::Component("NFS", ::analyzer::rpc::NFS_Analyzer::Instantiate)); AddComponent(new ::analyzer::Component("MOUNT", ::analyzer::rpc::MOUNT_Analyzer::Instantiate)); AddComponent(new ::analyzer::Component("Portmapper", ::analyzer::rpc::Portmapper_Analyzer::Instantiate)); - AddComponent(new ::analyzer::Component("Contents_RPC", 0)); - AddComponent(new ::analyzer::Component("Contents_NFS", 0)); + AddComponent(new ::analyzer::Component("Contents_RPC", nullptr)); + AddComponent(new ::analyzer::Component("Contents_NFS", nullptr)); plugin::Configuration config; config.name = "Zeek::RPC"; diff --git a/src/analyzer/protocol/rpc/Portmap.cc b/src/analyzer/protocol/rpc/Portmap.cc index c67d1b3c52..ad9fa37f02 100644 --- a/src/analyzer/protocol/rpc/Portmap.cc +++ b/src/analyzer/protocol/rpc/Portmap.cc @@ -79,7 +79,7 @@ bool PortmapperInterp::RPC_BuildReply(RPC_CallInfo* c, BifEnum::rpc_status statu int reply_len) { EventHandlerPtr event; - Val *reply = 0; + Val *reply = nullptr; int success = (status == BifEnum::RPC_SUCCESS); switch ( c->Proc() ) { @@ -208,7 +208,7 @@ Val* PortmapperInterp::ExtractMapping(const u_char*& buf, int& len) if ( ! buf ) { Unref(mapping); - return 0; + return nullptr; } return mapping; @@ -228,7 +228,7 @@ Val* PortmapperInterp::ExtractPortRequest(const u_char*& buf, int& len) if ( ! buf ) { Unref(pr); - return 0; + return nullptr; } return pr; @@ -249,7 +249,7 @@ Val* PortmapperInterp::ExtractCallItRequest(const u_char*& buf, int& len) if ( ! buf ) { Unref(c); - return 0; + return nullptr; } return c; @@ -307,7 +307,7 @@ void PortmapperInterp::Event(EventHandlerPtr f, Val* request, BifEnum::rpc_statu Portmapper_Analyzer::Portmapper_Analyzer(Connection* conn) : RPC_Analyzer("PORTMAPPER", conn, new PortmapperInterp(this)) { - orig_rpc = resp_rpc = 0; + orig_rpc = resp_rpc = nullptr; } Portmapper_Analyzer::~Portmapper_Analyzer() diff --git a/src/analyzer/protocol/rpc/RPC.h b/src/analyzer/protocol/rpc/RPC.h index 60488cd6d0..2aa8f14d31 100644 --- a/src/analyzer/protocol/rpc/RPC.h +++ b/src/analyzer/protocol/rpc/RPC.h @@ -54,7 +54,7 @@ public: void AddVal(Val* arg_v) { Unref(v); v = arg_v; } Val* RequestVal() const { return v; } - Val* TakeRequestVal() { Val* rv = v; v = 0; return rv; } + Val* TakeRequestVal() { Val* rv = v; v = nullptr; return rv; } bool CompareRexmit(const u_char* buf, int n) const; @@ -149,7 +149,7 @@ public: RPC_Reasm_Buffer() { maxsize = expected = 0; fill = processed = 0; - buf = 0; + buf = nullptr; }; ~RPC_Reasm_Buffer() { if (buf) delete [] buf; } diff --git a/src/analyzer/protocol/rpc/XDR.cc b/src/analyzer/protocol/rpc/XDR.cc index 95992d142c..1eddf96a04 100644 --- a/src/analyzer/protocol/rpc/XDR.cc +++ b/src/analyzer/protocol/rpc/XDR.cc @@ -17,7 +17,7 @@ uint32_t analyzer::rpc::extract_XDR_uint32(const u_char*& buf, int& len) if ( len < 4 ) { - buf = 0; + buf = nullptr; return 0; } @@ -36,7 +36,7 @@ uint64_t analyzer::rpc::extract_XDR_uint64(const u_char*& buf, int& len) { if ( ! buf || len < 8 ) { - buf = 0; + buf = nullptr; return 0; } @@ -50,7 +50,7 @@ double analyzer::rpc::extract_XDR_time(const u_char*& buf, int& len) { if ( ! buf || len < 8 ) { - buf = 0; + buf = nullptr; return 0.0; } @@ -64,15 +64,15 @@ const u_char* analyzer::rpc::extract_XDR_opaque(const u_char*& buf, int& len, in { n = int(extract_XDR_uint32(buf, len)); if ( ! buf ) - return 0; + return nullptr; if ( short_buf_ok ) n = std::min(n, len); if ( n < 0 || n > len || n > max_len ) { // ### Should really flag this as a different sort of error. - buf = 0; - return 0; + buf = nullptr; + return nullptr; } int n4 = ((n + 3) >> 2) << 2; // n rounded up to next multiple of 4 @@ -87,11 +87,11 @@ const u_char* analyzer::rpc::extract_XDR_opaque(const u_char*& buf, int& len, in const u_char* analyzer::rpc::extract_XDR_opaque_fixed(const u_char*& buf, int& len, int n) { if ( ! buf ) - return 0; + return nullptr; if ( n < 0 || n > len) { - buf = 0; - return 0; + buf = nullptr; + return nullptr; } int n4 = ((n + 3) >> 2) << 2; // n rounded up to next multiple of 4 diff --git a/src/analyzer/protocol/smb/Plugin.cc b/src/analyzer/protocol/smb/Plugin.cc index aaf84af9f5..2c10066eed 100644 --- a/src/analyzer/protocol/smb/Plugin.cc +++ b/src/analyzer/protocol/smb/Plugin.cc @@ -12,7 +12,7 @@ public: plugin::Configuration Configure() override { AddComponent(new ::analyzer::Component("SMB", ::analyzer::smb::SMB_Analyzer::Instantiate)); - AddComponent(new ::analyzer::Component("Contents_SMB", 0)); + AddComponent(new ::analyzer::Component("Contents_SMB", nullptr)); plugin::Configuration config; config.name = "Zeek::SMB"; diff --git a/src/analyzer/protocol/smtp/SMTP.cc b/src/analyzer/protocol/smtp/SMTP.cc index eee9ac81b8..0494bee0c0 100644 --- a/src/analyzer/protocol/smtp/SMTP.cc +++ b/src/analyzer/protocol/smtp/SMTP.cc @@ -43,8 +43,8 @@ SMTP_Analyzer::SMTP_Analyzer(Connection* conn) skip_data = false; orig_is_sender = true; - line_after_gap = 0; - mail = 0; + line_after_gap = nullptr; + mail = nullptr; UpdateState(first_cmd, 0, true); cl_orig = new tcp::ContentLine_Analyzer(conn, true); cl_orig->SetIsNULSensitive(true); @@ -103,7 +103,7 @@ void SMTP_Analyzer::Undelivered(uint64_t seq, int len, bool is_orig) if ( line_after_gap ) { delete line_after_gap; - line_after_gap = 0; + line_after_gap = nullptr; } pending_cmd_q.clear(); @@ -247,7 +247,7 @@ void SMTP_Analyzer::ProcessLine(int length, const char* line, bool orig) if ( cmd_code == -1 ) { Unexpected(true, "unknown command", cmd_len, cmd); - cmd = 0; + cmd = nullptr; } else NewCmd(cmd_code); @@ -921,7 +921,7 @@ void SMTP_Analyzer::BeginData(bool orig) { state = SMTP_IN_DATA; skip_data = false; // reset the flag at the beginning of the mail - if ( mail != 0 ) + if ( mail != nullptr ) { Weird("smtp_nested_mail_transaction"); mail->Done(); @@ -939,6 +939,6 @@ void SMTP_Analyzer::EndData() { mail->Done(); delete mail; - mail = 0; + mail = nullptr; } } diff --git a/src/analyzer/protocol/socks/SOCKS.cc b/src/analyzer/protocol/socks/SOCKS.cc index 83663f41b6..6490f38165 100644 --- a/src/analyzer/protocol/socks/SOCKS.cc +++ b/src/analyzer/protocol/socks/SOCKS.cc @@ -11,7 +11,7 @@ SOCKS_Analyzer::SOCKS_Analyzer(Connection* conn) { interp = new binpac::SOCKS::SOCKS_Conn(this); orig_done = resp_done = false; - pia = 0; + pia = nullptr; } SOCKS_Analyzer::~SOCKS_Analyzer() @@ -63,11 +63,11 @@ void SOCKS_Analyzer::DeliverStream(int len, const u_char* data, bool orig) pia = new pia::PIA_TCP(Conn()); if ( AddChildAnalyzer(pia) ) { - pia->FirstPacket(true, 0); - pia->FirstPacket(false, 0); + pia->FirstPacket(true, nullptr); + pia->FirstPacket(false, nullptr); } else - pia = 0; + pia = nullptr; } ForwardStream(len, data, orig); diff --git a/src/analyzer/protocol/stepping-stone/SteppingStone.cc b/src/analyzer/protocol/stepping-stone/SteppingStone.cc index 54351768f4..42332a59c5 100644 --- a/src/analyzer/protocol/stepping-stone/SteppingStone.cc +++ b/src/analyzer/protocol/stepping-stone/SteppingStone.cc @@ -158,7 +158,7 @@ SteppingStone_Analyzer::SteppingStone_Analyzer(Connection* c) { stp_manager = sessions->GetSTPManager(); - orig_endp = resp_endp = 0; + orig_endp = resp_endp = nullptr; orig_stream_pos = resp_stream_pos = 1; } @@ -179,9 +179,9 @@ void SteppingStone_Analyzer::DeliverPacket(int len, const u_char* data, ip, caplen); if ( is_orig ) - orig_endp->DataSent(network_time, seq, len, caplen, data, 0, 0); + orig_endp->DataSent(network_time, seq, len, caplen, data, nullptr, nullptr); else - resp_endp->DataSent(network_time, seq, len, caplen, data, 0, 0); + resp_endp->DataSent(network_time, seq, len, caplen, data, nullptr, nullptr); } void SteppingStone_Analyzer::DeliverStream(int len, const u_char* data, @@ -192,14 +192,14 @@ void SteppingStone_Analyzer::DeliverStream(int len, const u_char* data, if ( is_orig ) { orig_endp->DataSent(network_time, orig_stream_pos, len, len, - data, 0, 0); + data, nullptr, nullptr); orig_stream_pos += len; } else { resp_endp->DataSent(network_time, resp_stream_pos, len, len, - data, 0, 0); + data, nullptr, nullptr); resp_stream_pos += len; } } diff --git a/src/analyzer/protocol/tcp/ContentLine.cc b/src/analyzer/protocol/tcp/ContentLine.cc index 193a18fa65..5e0dfd81b2 100644 --- a/src/analyzer/protocol/tcp/ContentLine.cc +++ b/src/analyzer/protocol/tcp/ContentLine.cc @@ -24,7 +24,7 @@ void ContentLine_Analyzer::InitState() CR_LF_as_EOL = (CR_as_EOL | LF_as_EOL); skip_deliveries = false; skip_partial = false; - buf = 0; + buf = nullptr; seq_delivered_in_lines = 0; skip_pending = 0; seq = 0; diff --git a/src/analyzer/protocol/tcp/Plugin.cc b/src/analyzer/protocol/tcp/Plugin.cc index d96c3ca3ed..9f06936baa 100644 --- a/src/analyzer/protocol/tcp/Plugin.cc +++ b/src/analyzer/protocol/tcp/Plugin.cc @@ -13,8 +13,8 @@ public: { AddComponent(new ::analyzer::Component("TCP", ::analyzer::tcp::TCP_Analyzer::Instantiate)); AddComponent(new ::analyzer::Component("TCPStats", ::analyzer::tcp::TCPStats_Analyzer::Instantiate)); - AddComponent(new ::analyzer::Component("CONTENTLINE", 0)); - AddComponent(new ::analyzer::Component("Contents", 0)); + AddComponent(new ::analyzer::Component("CONTENTLINE", nullptr)); + AddComponent(new ::analyzer::Component("Contents", nullptr)); plugin::Configuration config; config.name = "Zeek::TCP"; diff --git a/src/analyzer/protocol/tcp/TCP.cc b/src/analyzer/protocol/tcp/TCP.cc index 6d6ad3a41b..8a8f300397 100644 --- a/src/analyzer/protocol/tcp/TCP.cc +++ b/src/analyzer/protocol/tcp/TCP.cc @@ -192,7 +192,7 @@ analyzer::Analyzer* TCP_Analyzer::FindChild(ID arg_id) return child; } - return 0; + return nullptr; } analyzer::Analyzer* TCP_Analyzer::FindChild(Tag arg_tag) @@ -209,7 +209,7 @@ analyzer::Analyzer* TCP_Analyzer::FindChild(Tag arg_tag) return child; } - return 0; + return nullptr; } bool TCP_Analyzer::RemoveChildAnalyzer(ID id) @@ -253,7 +253,7 @@ const struct tcphdr* TCP_Analyzer::ExtractTCP_Header(const u_char*& data, if ( tcp_hdr_len < sizeof(struct tcphdr) ) { Weird("bad_TCP_header_len"); - return 0; + return nullptr; } if ( tcp_hdr_len > uint32_t(len) || @@ -262,7 +262,7 @@ const struct tcphdr* TCP_Analyzer::ExtractTCP_Header(const u_char*& data, // This can happen even with the above test, due to TCP // options. Weird("truncated_header"); - return 0; + return nullptr; } len -= tcp_hdr_len; // remove TCP header @@ -1587,8 +1587,8 @@ void TCP_Analyzer::SetContentsFile(unsigned int direction, BroFile* f) { if ( direction == CONTENTS_NONE ) { - orig->SetContentsFile(0); - resp->SetContentsFile(0); + orig->SetContentsFile(nullptr); + resp->SetContentsFile(nullptr); } else @@ -1604,7 +1604,7 @@ BroFile* TCP_Analyzer::GetContentsFile(unsigned int direction) const { switch ( direction ) { case CONTENTS_NONE: - return 0; + return nullptr; case CONTENTS_ORIG: return orig->GetContentsFile(); @@ -1615,7 +1615,7 @@ BroFile* TCP_Analyzer::GetContentsFile(unsigned int direction) const case CONTENTS_BOTH: if ( orig->GetContentsFile() != resp->GetContentsFile()) // This is an "error". - return 0; + return nullptr; else return orig->GetContentsFile(); @@ -1625,7 +1625,7 @@ BroFile* TCP_Analyzer::GetContentsFile(unsigned int direction) const reporter->Error("bad direction %u in TCP_Analyzer::GetContentsFile", direction); - return 0; + return nullptr; } void TCP_Analyzer::ConnectionClosed(TCP_Endpoint* endpoint, TCP_Endpoint* peer, @@ -2127,7 +2127,7 @@ void TCPStats_Analyzer::DeliverPacket(int len, const u_char* data, bool is_orig, TCP_ApplicationAnalyzer::DeliverPacket(len, data, is_orig, seq, ip, caplen); if ( is_orig ) - orig_stats->DataSent(network_time, seq, len, caplen, data, ip, 0); + orig_stats->DataSent(network_time, seq, len, caplen, data, ip, nullptr); else - resp_stats->DataSent(network_time, seq, len, caplen, data, ip, 0); + resp_stats->DataSent(network_time, seq, len, caplen, data, ip, nullptr); } diff --git a/src/analyzer/protocol/tcp/TCP.h b/src/analyzer/protocol/tcp/TCP.h index 1a2d29c8b2..5e7781f62f 100644 --- a/src/analyzer/protocol/tcp/TCP.h +++ b/src/analyzer/protocol/tcp/TCP.h @@ -161,7 +161,7 @@ protected: // A couple utility functions that may also be useful to derived analyzers. static uint64_t get_relative_seq(const TCP_Endpoint* endpoint, uint32_t cur_base, uint32_t last, - uint32_t wraps, bool* underflow = 0); + uint32_t wraps, bool* underflow = nullptr); static int get_segment_len(int payload_len, TCP_Flags flags); @@ -192,12 +192,10 @@ private: class TCP_ApplicationAnalyzer : public analyzer::Analyzer { public: TCP_ApplicationAnalyzer(const char* name, Connection* conn) - : Analyzer(name, conn) - { tcp = 0; } + : Analyzer(name, conn), tcp(nullptr) { } explicit TCP_ApplicationAnalyzer(Connection* conn) - : Analyzer(conn) - { tcp = 0; } + : Analyzer(conn), tcp(nullptr) { } ~TCP_ApplicationAnalyzer() override { } @@ -235,7 +233,7 @@ public: // This suppresses violations if the TCP connection wasn't // fully established. void ProtocolViolation(const char* reason, - const char* data = 0, int len = 0) override; + const char* data = nullptr, int len = 0) override; // "name" and "val" both now belong to this object, which needs to // delete them when done with them. diff --git a/src/analyzer/protocol/tcp/TCP_Endpoint.cc b/src/analyzer/protocol/tcp/TCP_Endpoint.cc index 59f0b21778..f0fb129d6d 100644 --- a/src/analyzer/protocol/tcp/TCP_Endpoint.cc +++ b/src/analyzer/protocol/tcp/TCP_Endpoint.cc @@ -16,9 +16,9 @@ using namespace analyzer::tcp; TCP_Endpoint::TCP_Endpoint(TCP_Analyzer* arg_analyzer, bool arg_is_orig) { - contents_processor = 0; + contents_processor = nullptr; prev_state = state = TCP_ENDPOINT_INACTIVE; - peer = 0; + peer = nullptr; start_time = last_time = 0.0; start_seq = last_seq = ack_seq = 0; seq_wraps = ack_wraps = 0; @@ -29,7 +29,7 @@ TCP_Endpoint::TCP_Endpoint(TCP_Analyzer* arg_analyzer, bool arg_is_orig) FIN_seq = 0; SYN_cnt = FIN_cnt = RST_cnt = 0; did_close = false; - contents_file = 0; + contents_file = nullptr; tcp_analyzer = arg_analyzer; is_orig = arg_is_orig; diff --git a/src/analyzer/protocol/tcp/TCP_Endpoint.h b/src/analyzer/protocol/tcp/TCP_Endpoint.h index 79c9ee2849..e72016e4a2 100644 --- a/src/analyzer/protocol/tcp/TCP_Endpoint.h +++ b/src/analyzer/protocol/tcp/TCP_Endpoint.h @@ -141,7 +141,7 @@ public: Connection* Conn() const; - bool HasContents() const { return contents_processor != 0; } + bool HasContents() const { return contents_processor != nullptr; } bool HadGap() const; inline bool IsOrig() const { return is_orig; } diff --git a/src/analyzer/protocol/tcp/TCP_Reassembler.cc b/src/analyzer/protocol/tcp/TCP_Reassembler.cc index f77cbda026..697e8d7325 100644 --- a/src/analyzer/protocol/tcp/TCP_Reassembler.cc +++ b/src/analyzer/protocol/tcp/TCP_Reassembler.cc @@ -30,7 +30,7 @@ TCP_Reassembler::TCP_Reassembler(analyzer::Analyzer* arg_dst_analyzer, type = arg_type; endp = arg_endp; had_gap = false; - record_contents_file = 0; + record_contents_file = nullptr; deliver_tcp_contents = false; skip_deliveries = false; did_EOF = false; diff --git a/src/analyzer/protocol/tcp/functions.bif b/src/analyzer/protocol/tcp/functions.bif index 5c6448eec1..7b0e2b6876 100644 --- a/src/analyzer/protocol/tcp/functions.bif +++ b/src/analyzer/protocol/tcp/functions.bif @@ -121,7 +121,7 @@ function set_contents_file%(cid: conn_id, direction: count, f: file%): bool function get_contents_file%(cid: conn_id, direction: count%): file %{ Connection* c = sessions->FindConnection(cid); - BroFile* f = c ? c->GetRootAnalyzer()->GetContentsFile(direction) : 0; + BroFile* f = c ? c->GetRootAnalyzer()->GetContentsFile(direction) : nullptr; if ( f ) { diff --git a/src/analyzer/protocol/teredo/Teredo.cc b/src/analyzer/protocol/teredo/Teredo.cc index 2089fd3f3e..3b1667be29 100644 --- a/src/analyzer/protocol/teredo/Teredo.cc +++ b/src/analyzer/protocol/teredo/Teredo.cc @@ -98,9 +98,9 @@ bool TeredoEncapsulation::DoParse(const u_char* data, int& len, RecordVal* TeredoEncapsulation::BuildVal(const IP_Hdr* inner) const { - static RecordType* teredo_hdr_type = 0; - static RecordType* teredo_auth_type = 0; - static RecordType* teredo_origin_type = 0; + static RecordType* teredo_hdr_type = nullptr; + static RecordType* teredo_auth_type = nullptr; + static RecordType* teredo_origin_type = nullptr; if ( ! teredo_hdr_type ) { @@ -167,7 +167,7 @@ void Teredo_Analyzer::DeliverPacket(int len, const u_char* data, bool orig, return; } - IP_Hdr* inner = 0; + IP_Hdr* inner = nullptr; int rslt = sessions->ParseIPPacket(len, te.InnerIP(), IPPROTO_IPV6, inner); if ( rslt > 0 ) @@ -201,33 +201,33 @@ void Teredo_Analyzer::DeliverPacket(int len, const u_char* data, bool orig, return; } - Val* teredo_hdr = 0; + Val* teredo_hdr = nullptr; if ( teredo_packet ) { teredo_hdr = te.BuildVal(inner); - Conn()->Event(teredo_packet, 0, teredo_hdr); + Conn()->Event(teredo_packet, nullptr, teredo_hdr); } if ( te.Authentication() && teredo_authentication ) { teredo_hdr = teredo_hdr ? teredo_hdr->Ref() : te.BuildVal(inner); - Conn()->Event(teredo_authentication, 0, teredo_hdr); + Conn()->Event(teredo_authentication, nullptr, teredo_hdr); } if ( te.OriginIndication() && teredo_origin_indication ) { teredo_hdr = teredo_hdr ? teredo_hdr->Ref() : te.BuildVal(inner); - Conn()->Event(teredo_origin_indication, 0, teredo_hdr); + Conn()->Event(teredo_origin_indication, nullptr, teredo_hdr); } if ( inner->NextProto() == IPPROTO_NONE && teredo_bubble ) { teredo_hdr = teredo_hdr ? teredo_hdr->Ref() : te.BuildVal(inner); - Conn()->Event(teredo_bubble, 0, teredo_hdr); + Conn()->Event(teredo_bubble, nullptr, teredo_hdr); } EncapsulatingConn ec(Conn(), BifEnum::Tunnel::TEREDO); - sessions->DoNextInnerPacket(network_time, 0, inner, e, ec); + sessions->DoNextInnerPacket(network_time, nullptr, inner, e, ec); } diff --git a/src/analyzer/protocol/teredo/Teredo.h b/src/analyzer/protocol/teredo/Teredo.h index e76b6b7ba8..3d0fd00ffe 100644 --- a/src/analyzer/protocol/teredo/Teredo.h +++ b/src/analyzer/protocol/teredo/Teredo.h @@ -55,7 +55,7 @@ protected: class TeredoEncapsulation { public: explicit TeredoEncapsulation(const Teredo_Analyzer* ta) - : inner_ip(0), origin_indication(0), auth(0), analyzer(ta) + : inner_ip(nullptr), origin_indication(nullptr), auth(nullptr), analyzer(ta) {} /** diff --git a/src/analyzer/protocol/vxlan/VXLAN.cc b/src/analyzer/protocol/vxlan/VXLAN.cc index b7ed5322f7..ff41444295 100644 --- a/src/analyzer/protocol/vxlan/VXLAN.cc +++ b/src/analyzer/protocol/vxlan/VXLAN.cc @@ -101,7 +101,7 @@ void VXLAN_Analyzer::DeliverPacket(int len, const u_char* data, bool orig, ProtocolConfirmation(); if ( vxlan_packet ) - Conn()->Event(vxlan_packet, 0, inner->BuildPktHdrVal(), + Conn()->Event(vxlan_packet, nullptr, inner->BuildPktHdrVal(), val_mgr->GetCount(vni)); EncapsulatingConn ec(Conn(), BifEnum::Tunnel::VXLAN); diff --git a/src/analyzer/protocol/zip/Plugin.cc b/src/analyzer/protocol/zip/Plugin.cc index e80d4c6a8c..d59cde2ca0 100644 --- a/src/analyzer/protocol/zip/Plugin.cc +++ b/src/analyzer/protocol/zip/Plugin.cc @@ -11,7 +11,7 @@ class Plugin : public plugin::Plugin { public: plugin::Configuration Configure() override { - AddComponent(new ::analyzer::Component("ZIP", 0)); + AddComponent(new ::analyzer::Component("ZIP", nullptr)); plugin::Configuration config; config.name = "Zeek::ZIP"; diff --git a/src/analyzer/protocol/zip/ZIP.cc b/src/analyzer/protocol/zip/ZIP.cc index d44c6353cd..4b94912e75 100644 --- a/src/analyzer/protocol/zip/ZIP.cc +++ b/src/analyzer/protocol/zip/ZIP.cc @@ -7,7 +7,7 @@ using namespace analyzer::zip; ZIP_Analyzer::ZIP_Analyzer(Connection* conn, bool orig, Method arg_method) : tcp::TCP_SupportAnalyzer("ZIP", conn, orig) { - zip = 0; + zip = nullptr; zip_status = Z_OK; method = arg_method; @@ -26,7 +26,7 @@ ZIP_Analyzer::ZIP_Analyzer(Connection* conn, bool orig, Method arg_method) { Weird("inflate_init_failed"); delete zip; - zip = 0; + zip = nullptr; } }