Fix crash on using some deprecated environment variables

If the global Reporter hasn't been created before trying to use a
deprecated environment variable, emit the warning to stderr directly
instead of via Reporter.

Fixes GH-989
This commit is contained in:
Jon Siwek 2020-05-28 15:23:04 -07:00
parent 138c9402c3
commit 1c08be1c0f

View file

@ -2365,7 +2365,12 @@ char* zeekenv(const char* name)
auto val = getenv(it->second);
if ( val && starts_with(it->second, "BRO_") )
{
if ( reporter )
reporter->Warning("Using legacy environment variable %s, support will be removed in Zeek v4.1; use %s instead", it->second, name);
else
fprintf(stderr, "Using legacy environment variable %s, support will be removed in Zeek v4.1; use %s instead\n", it->second, name);
}
return val;
}