From 1c08be1c0f89e9a8437ee230fbdbcd306485847b Mon Sep 17 00:00:00 2001 From: Jon Siwek Date: Thu, 28 May 2020 15:23:04 -0700 Subject: [PATCH] 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 --- src/util.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/util.cc b/src/util.cc index 7b3394e8d7..8b8daf4ec0 100644 --- a/src/util.cc +++ b/src/util.cc @@ -2365,7 +2365,12 @@ char* zeekenv(const char* name) auto val = getenv(it->second); if ( val && starts_with(it->second, "BRO_") ) - reporter->Warning("Using legacy environment variable %s, support will be removed in Zeek v4.1; use %s instead", it->second, name); + { + 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; }