aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichał Łyszczek <michal.lyszczek@bofc.pl>2021-05-19 01:33:53 +0200
committerMichał Łyszczek <michal.lyszczek@bofc.pl>2021-05-19 01:33:53 +0200
commit0b506e51d0f907e1f8d6a0efda6cb035f50d34ce (patch)
tree2c565ae7eaa6ef1d078c5045d25b82f38c5ba37d
parent3e52cf717ca189447862bec5635201785688dd3f (diff)
downloadpsmq-0b506e51d0f907e1f8d6a0efda6cb035f50d34ce.tar.gz
psmq-0b506e51d0f907e1f8d6a0efda6cb035f50d34ce.tar.bz2
psmq-0b506e51d0f907e1f8d6a0efda6cb035f50d34ce.zip
src/cfg.c: fix potential segfault when printing config
When program log is not set it is set to NULL, which is passed to strlen, which can cause segfault. Signed-off-by: Michał Łyszczek <michal.lyszczek@bofc.pl>
-rw-r--r--src/cfg.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/cfg.c b/src/cfg.c
index 4d5cab8..916d00e 100644
--- a/src/cfg.c
+++ b/src/cfg.c
@@ -243,7 +243,10 @@ void psmqd_cfg_print(void)
#endif
CONFIG_PRINT(log_level, "%d");
CONFIG_PRINT(colorful_output, "%d");
- CONFIG_PRINT(program_log, "%s");
+ if (g_psmqd_cfg.program_log)
+ CONFIG_PRINT(program_log, "%s");
+ else
+ CONFIG_PRINT(program_log, "(stderr)");
CONFIG_PRINT(broker_name, "%s");
CONFIG_PRINT(broker_maxmsg, "%d");
CONFIG_PRINT(remove_queue, "%d");