Bug fixes.

- Fixing a crash with an invalid pointer.

- Fixing a namespacing problem with is_ftp_data_conn() and check_relay_3().

- Fixing the do-we-have-an-event-handler-defined check.

Standard test-suite passes.

Seth, I think you can give it a try now ...
This commit is contained in:
Robin Sommer 2011-03-10 17:53:09 -08:00
parent 871561939b
commit 45ebfbb2b8
8 changed files with 29 additions and 17 deletions

View file

@ -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 )

View file

@ -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;

View file

@ -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:
# names.
export
{
global SMTP::check_relay_3:
function(session: MIME::mime_session_info, msg_id: string);
global check_relay_4:
global SMTP::check_relay_4:
function(session: MIME::mime_session_info, content_hash: string);
module MIME;
}
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 = {

View file

@ -23,6 +23,11 @@ EventHandler::~EventHandler()
delete [] group;
}
EventHandler::operator bool() const
{
return enabled && ((local && local->HasBodies()) || receivers.length());
}
FuncType* EventHandler::FType()
{
if ( type )

View file

@ -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; }

View file

@ -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);
}

View file

@ -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<Body>& GetBodies() const { return bodies; }
const vector<Body>& 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;

View file

@ -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);