diff --git a/src/RemoteSerializer.cc b/src/RemoteSerializer.cc index af52683b76..56f0772a26 100644 --- a/src/RemoteSerializer.cc +++ b/src/RemoteSerializer.cc @@ -2734,6 +2734,30 @@ void RemoteSerializer::GotEvent(const char* name, double time, e->handler = event; e->args = args; + // If needed, coerce received record arguments to the expected record type. + if ( e->handler->FType() ) + { + const type_list* arg_types = e->handler->FType()->ArgTypes()->Types(); + loop_over_list(*args, i) + { + Val* v = (*args)[i]; + BroType* v_t = v->Type(); + BroType* arg_t = (*arg_types)[i]; + if ( v_t->Tag() == TYPE_RECORD && arg_t->Tag() == TYPE_RECORD ) + { + if ( ! same_type(v_t, arg_t) ) + { + Val* nv = v->AsRecordVal()->CoerceTo(arg_t->AsRecordType()); + if ( nv ) + { + args->replace(i, nv); + Unref(v); + } + } + } + } + } + events.append(e); } diff --git a/testing/btest/Baseline/istate.pybroccoli/bro..stdout b/testing/btest/Baseline/istate.pybroccoli/bro..stdout index 9eec3a4550..8b772e094f 100644 --- a/testing/btest/Baseline/istate.pybroccoli/bro..stdout +++ b/testing/btest/Baseline/istate.pybroccoli/bro..stdout @@ -14,6 +14,6 @@ Servus [a=42, b=6.6.7.7] 42, 6.6.7.7 ==== coerced record -[a=13, b=, c=helloworld] +[one=, a=13, b=, c=helloworld, d=] 13 helloworld