aboutsummaryrefslogtreecommitdiffstats
path: root/wsutil
diff options
context:
space:
mode:
authorJoão Valverde <j@v6e.pt>2021-06-24 02:18:03 +0100
committerJoão Valverde <j@v6e.pt>2021-06-24 02:26:28 +0100
commita370024ca968c38e41522a3b3695d315934f0a32 (patch)
tree4356a32f0924ac25e42123236ddc3e111e5a833c /wsutil
parenteb3417e38f70623a271997eb5ed69bd4f522d16a (diff)
wslog: Fix initialization with invalid environment
We can't write to stderr outside of the default writer context. Wireshark and tshark will block if we do that and dumpcap is running as capture child.
Diffstat (limited to 'wsutil')
-rw-r--r--wsutil/wslog.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/wsutil/wslog.c b/wsutil/wslog.c
index 53d8fd8f63..3f505db7c4 100644
--- a/wsutil/wslog.c
+++ b/wsutil/wslog.c
@@ -526,6 +526,11 @@ enum ws_log_level ws_log_set_fatal_str(const char *str_level)
}
+/*
+ * We can't write to stderr in ws_log_init() because dumpcap uses stderr
+ * to communicate with the parent and it will block. Any failures are
+ * therefore ignored.
+ */
void ws_log_init(const char *progname, ws_log_writer_cb *writer)
{
const char *env;
@@ -552,17 +557,17 @@ void ws_log_init(const char *progname, ws_log_writer_cb *writer)
current_log_level = DEFAULT_LOG_LEVEL;
env = g_getenv(ENV_VAR_LEVEL);
- if (env != NULL && ws_log_set_level_str(env) == LOG_LEVEL_NONE)
- fprintf(stderr, "Ignoring invalid environment value %s=\"%s\".\n", ENV_VAR_LEVEL, env);
+ if (env != NULL)
+ ws_log_set_level_str(env);
+
+ env = g_getenv(ENV_VAR_FATAL);
+ if (env != NULL)
+ ws_log_set_fatal_str(env);
env = g_getenv(ENV_VAR_DOMAINS);
if (env != NULL)
ws_log_set_domain_filter(env);
- env = g_getenv(ENV_VAR_FATAL);
- if (env != NULL && ws_log_set_fatal_str(env) == LOG_LEVEL_NONE)
- fprintf(stderr, "Ignoring invalid environment value %s=\"%s\".\n", ENV_VAR_FATAL, env);
-
env = g_getenv(ENV_VAR_DEBUG);
if (env != NULL)
ws_log_set_debug_filter(env);