From d969f8621de905b48460d33324c7768d083b130d Mon Sep 17 00:00:00 2001 From: Mattias Jernberg Date: Mon, 8 Jul 2019 12:15:59 +0200 Subject: [PATCH] Fix syslog output payload does not appear to be reliably null terminated and leaks data. Use size to the formatter to reliably terminate messages. --- include/spdlog/sinks/syslog_sink.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/spdlog/sinks/syslog_sink.h b/include/spdlog/sinks/syslog_sink.h index 5f690d3d..ccc70693 100644 --- a/include/spdlog/sinks/syslog_sink.h +++ b/include/spdlog/sinks/syslog_sink.h @@ -59,7 +59,8 @@ protected: payload = msg.payload; } - ::syslog(syslog_prio_from_level(msg), "%s", payload.data()); + int length = std::min::type>(std::numeric_limits::max(), payload.size()); + ::syslog(syslog_prio_from_level(msg), "%.*s", length, payload.data()); } void flush_() override {}