mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
GH-165: Fix global initializations that indirectly use builtin types
This commit is contained in:
parent
4a8640d702
commit
5ed13284c3
7 changed files with 30 additions and 4 deletions
|
@ -930,6 +930,7 @@ void init_primary_bifs()
|
||||||
#include "option.bif.func_init"
|
#include "option.bif.func_init"
|
||||||
#include "supervisor.bif.func_init"
|
#include "supervisor.bif.func_init"
|
||||||
|
|
||||||
|
init_builtin_types();
|
||||||
did_builtin_init = true;
|
did_builtin_init = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,7 @@ FuncPtr id::find_func(std::string_view name)
|
||||||
return v->AsFuncPtr();
|
return v->AsFuncPtr();
|
||||||
}
|
}
|
||||||
|
|
||||||
void id::detail::init()
|
void id::detail::init_types()
|
||||||
{
|
{
|
||||||
conn_id = id::find_type<RecordType>("conn_id");
|
conn_id = id::find_type<RecordType>("conn_id");
|
||||||
endpoint = id::find_type<RecordType>("endpoint");
|
endpoint = id::find_type<RecordType>("endpoint");
|
||||||
|
|
2
src/ID.h
2
src/ID.h
|
@ -272,7 +272,7 @@ extern VectorTypePtr index_vec;
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
void init();
|
void init_types();
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
} // namespace zeek::id
|
} // namespace zeek::id
|
||||||
|
|
|
@ -207,11 +207,15 @@ static void bif_init_event_handlers()
|
||||||
static void bif_init_net_var()
|
static void bif_init_net_var()
|
||||||
{
|
{
|
||||||
#include "const.bif.netvar_init"
|
#include "const.bif.netvar_init"
|
||||||
#include "types.bif.netvar_init"
|
|
||||||
#include "reporter.bif.netvar_init"
|
#include "reporter.bif.netvar_init"
|
||||||
#include "supervisor.bif.netvar_init"
|
#include "supervisor.bif.netvar_init"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void init_bif_types()
|
||||||
|
{
|
||||||
|
#include "types.bif.netvar_init"
|
||||||
|
}
|
||||||
|
|
||||||
#include "const.bif.netvar_def"
|
#include "const.bif.netvar_def"
|
||||||
#include "types.bif.netvar_def"
|
#include "types.bif.netvar_def"
|
||||||
#include "event.bif.netvar_def"
|
#include "event.bif.netvar_def"
|
||||||
|
@ -240,11 +244,16 @@ void init_general_global_var()
|
||||||
|
|
||||||
extern void zeek_legacy_netvar_init();
|
extern void zeek_legacy_netvar_init();
|
||||||
|
|
||||||
|
void init_builtin_types()
|
||||||
|
{
|
||||||
|
init_bif_types();
|
||||||
|
id::detail::init_types();
|
||||||
|
}
|
||||||
|
|
||||||
void init_net_var()
|
void init_net_var()
|
||||||
{
|
{
|
||||||
bif_init_net_var();
|
bif_init_net_var();
|
||||||
|
|
||||||
id::detail::init();
|
|
||||||
zeek_legacy_netvar_init();
|
zeek_legacy_netvar_init();
|
||||||
|
|
||||||
ignore_checksums = id::find_val("ignore_checksums")->AsBool();
|
ignore_checksums = id::find_val("ignore_checksums")->AsBool();
|
||||||
|
|
|
@ -103,6 +103,7 @@ extern void init_general_global_var();
|
||||||
|
|
||||||
extern void init_event_handlers();
|
extern void init_event_handlers();
|
||||||
extern void init_net_var();
|
extern void init_net_var();
|
||||||
|
extern void init_builtin_types();
|
||||||
|
|
||||||
} // namespace zeek::detail
|
} // namespace zeek::detail
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
tcp and port 80
|
|
@ -0,0 +1,14 @@
|
||||||
|
# @TEST-EXEC: zeek -b %INPUT >out
|
||||||
|
# @TEST-EXEC: btest-diff out
|
||||||
|
|
||||||
|
# This test isn't specifically testing the PacketFilter functionality, rather
|
||||||
|
# that a global variable can be initialized using a BIF call and that BIF call
|
||||||
|
# can make use of some global type pointers to builtin types/aliases.
|
||||||
|
|
||||||
|
@load base/frameworks/packet-filter
|
||||||
|
redef PacketFilter::restricted_filter = PacketFilter::port_to_bpf(80/tcp);
|
||||||
|
|
||||||
|
event zeek_init()
|
||||||
|
{
|
||||||
|
print PacketFilter::restricted_filter;
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue