From 36cb30d47d84619c41cfea755a6122f3c2e7c75c Mon Sep 17 00:00:00 2001 From: iphydf Date: Wed, 18 Mar 2020 13:42:50 +0000 Subject: Check that LOGGER macros are only called with string literals. Avoid any dynamic format strings, even ones like `cond ? "str1" : "str2"`. --- toxcore/network.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/toxcore/network.c b/toxcore/network.c index d6d5bfd4..da51fdc3 100644 --- a/toxcore/network.c +++ b/toxcore/network.c @@ -871,8 +871,13 @@ Networking_Core *new_networking_ex(const Logger *log, IP ip, uint16_t port_from, int neterror = net_error(); const char *strerror = net_new_strerror(neterror); - LOGGER_DEBUG(log, res < 0 ? "Failed to activate local multicast membership. (%d, %s)" : - "Local multicast group FF02::1 joined successfully. (%d, %s)", neterror, strerror); + + if (res < 0) { + LOGGER_DEBUG(log, "Failed to activate local multicast membership. (%d, %s)", neterror, strerror); + } else { + LOGGER_DEBUG(log, "Local multicast group FF02::1 joined successfully. (%d, %s)", neterror, strerror); + } + net_kill_strerror(strerror); } -- cgit v1.2.3