diff --git a/policy/conn.bro b/policy/conn.bro index 134ac9db13..b0301c3fbb 100644 --- a/policy/conn.bro +++ b/policy/conn.bro @@ -14,7 +14,9 @@ const conn_closed = { TCP_CLOSED, TCP_RESET }; global have_FTP = F; # if true, we've loaded ftp.bro global have_SMTP = F; # if true, we've loaded smtp.bro -global is_ftp_data_conn: function(c: connection): bool; + +# TODO: Do we have a nicer way of doing this? +export { global FTP::is_ftp_data_conn: function(c: connection): bool; } # Whether to include connection state history in the logs generated # by record_connection. @@ -186,7 +188,7 @@ function determine_service_non_DPD(c: connection) : string return i; # return first; } - else if ( have_FTP && is_ftp_data_conn(c) ) + else if ( have_FTP && FTP::is_ftp_data_conn(c) ) return port_names[20/tcp]; else if ( [c$id$resp_h, c$id$resp_p] in RPC_server_map ) diff --git a/policy/firewall.bro b/policy/firewall.bro index adbf7a450c..59a92206b4 100644 --- a/policy/firewall.bro +++ b/policy/firewall.bro @@ -151,7 +151,7 @@ function do_match(c: connection, r: rule): bool return F; } - if ( r$is_ftp && ! is_ftp_data_conn(c) ) + if ( r$is_ftp && ! FTP::is_ftp_data_conn(c) ) return F; return T; diff --git a/policy/mime.bro b/policy/mime.bro index 7f923aac08..73a4ecefee 100644 --- a/policy/mime.bro +++ b/policy/mime.bro @@ -74,13 +74,14 @@ function mime_header_subject(session: mime_session_info, ### This is a bit clunky. These are functions we call out to, defined # elsewhere. The way we really ought to do this is to have them passed # in during initialization. But for now, we presume knowledge of their -# names in global scope. -module GLOBAL; -global check_relay_3: - function(session: MIME::mime_session_info, msg_id: string); -global check_relay_4: - function(session: MIME::mime_session_info, content_hash: string); -module MIME; +# names. +export + { + global SMTP::check_relay_3: + function(session: MIME::mime_session_info, msg_id: string); + global SMTP::check_relay_4: + function(session: MIME::mime_session_info, content_hash: string); + } function mime_header_message_id(session: mime_session_info, name: string, arg: string) { @@ -107,7 +108,7 @@ function mime_header_message_id(session: mime_session_info, name: string, arg: s s = t[1]; if ( session$level == 1 && SMTP::process_smtp_relay ) - check_relay_3(session, s); + SMTP::check_relay_3(session, s); } redef mime_header_handler = { diff --git a/src/EventHandler.cc b/src/EventHandler.cc index 9df18ab007..9cc5306c9c 100644 --- a/src/EventHandler.cc +++ b/src/EventHandler.cc @@ -23,6 +23,11 @@ EventHandler::~EventHandler() delete [] group; } +EventHandler::operator bool() const + { + return enabled && ((local && local->HasBodies()) || receivers.length()); + } + FuncType* EventHandler::FType() { if ( type ) diff --git a/src/EventHandler.h b/src/EventHandler.h index de4d1a1458..4320134d50 100644 --- a/src/EventHandler.h +++ b/src/EventHandler.h @@ -34,8 +34,7 @@ public: void Call(val_list* vl, bool no_remote = false); // Returns true if there is at least one local or remote handler. - operator bool() const - { return enabled && (local || receivers.length()); } + operator bool() const; void SetUsed() { used = true; } bool Used() { return used; } diff --git a/src/Expr.cc b/src/Expr.cc index 0f186b1f99..1a4c42cf95 100644 --- a/src/Expr.cc +++ b/src/Expr.cc @@ -4030,7 +4030,10 @@ Val* RecordCoerceExpr::Fold(Val* v) const for ( int i = 0; i < map_size; ++i ) { if ( map[i] >= 0 ) - val->Assign(i, rv->Lookup(map[i])->Ref()); + { + Val* v = rv->Lookup(map[i]); + val->Assign(i, v ? v->Ref() : 0); + } else val->Assign(i, 0); } diff --git a/src/Func.h b/src/Func.h index f82b9ee539..b6cfab893b 100644 --- a/src/Func.h +++ b/src/Func.h @@ -15,6 +15,7 @@ class FuncType; class Stmt; class Frame; class ID; +class CallExpr; class Func : public BroObj { public: @@ -36,7 +37,8 @@ public: { return priority > other.priority; } // reverse sort }; - virtual const vector& GetBodies() const { return bodies; } + const vector& GetBodies() const { return bodies; } + bool HasBodies() const { return bodies.size(); } // virtual Val* Call(ListExpr* args) const = 0; virtual Val* Call(val_list* args, Frame* parent = 0) const = 0; diff --git a/src/Type.cc b/src/Type.cc index b201373453..810a08b443 100644 --- a/src/Type.cc +++ b/src/Type.cc @@ -1463,9 +1463,9 @@ int same_type(const BroType* t1, const BroType* t2, int is_init) int same_attrs(const Attributes* a1, const Attributes* a2) { if ( ! a1 ) - return (a2 != 0); + return (a2 == 0); - if ( ! a2 ) + if ( a2 ) return 0; return (*a1 == *a2);