mirror of
https://github.com/zeek/zeek.git
synced 2025-10-09 10:08:20 +00:00
Fix potential thread safety issue with zeekenv util function
Observed segfault accessing the local static std::map of zeekenv() from a logging thread, but only in non-debug builds using Apple/Clang compiler, not in a debug build or GCC. Don't quite get this behavior since static local variable initialization is supposed to be thread-safe since C++11, but moving to a global static works and is "more efficient" anyway since there's no longer any run-time overhead.
This commit is contained in:
parent
0d34a1c646
commit
9a72a7117d
1 changed files with 16 additions and 16 deletions
|
@ -1842,9 +1842,7 @@ void bro_strerror_r(int bro_errno, char* buf, size_t buflen)
|
||||||
strerror_r_helper(res, buf, buflen);
|
strerror_r_helper(res, buf, buflen);
|
||||||
}
|
}
|
||||||
|
|
||||||
char* zeekenv(const char* name)
|
static const std::map<const char*, const char*, CompareString> legacy_vars = {
|
||||||
{
|
|
||||||
static std::map<const char*, const char*, CompareString> legacy_vars = {
|
|
||||||
{ "ZEEKPATH", "BROPATH" },
|
{ "ZEEKPATH", "BROPATH" },
|
||||||
{ "ZEEK_PLUGIN_PATH", "BRO_PLUGIN_PATH" },
|
{ "ZEEK_PLUGIN_PATH", "BRO_PLUGIN_PATH" },
|
||||||
{ "ZEEK_PLUGIN_ACTIVATE", "BRO_PLUGIN_ACTIVATE" },
|
{ "ZEEK_PLUGIN_ACTIVATE", "BRO_PLUGIN_ACTIVATE" },
|
||||||
|
@ -1858,8 +1856,10 @@ char* zeekenv(const char* name)
|
||||||
{ "ZEEK_BROKER_MAX_THREADS", "BRO_BROKER_MAX_THREADS" },
|
{ "ZEEK_BROKER_MAX_THREADS", "BRO_BROKER_MAX_THREADS" },
|
||||||
{ "ZEEK_DEFAULT_LISTEN_ADDRESS", "BRO_DEFAULT_LISTEN_ADDRESS" },
|
{ "ZEEK_DEFAULT_LISTEN_ADDRESS", "BRO_DEFAULT_LISTEN_ADDRESS" },
|
||||||
{ "ZEEK_DEFAULT_LISTEN_RETRY", "BRO_DEFAULT_LISTEN_RETRY" },
|
{ "ZEEK_DEFAULT_LISTEN_RETRY", "BRO_DEFAULT_LISTEN_RETRY" },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
char* zeekenv(const char* name)
|
||||||
|
{
|
||||||
auto rval = getenv(name);
|
auto rval = getenv(name);
|
||||||
|
|
||||||
if ( rval )
|
if ( rval )
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue