Fix syslog output

payload does not appear to be reliably null terminated and leaks
data. Use size to the formatter to reliably terminate messages.
This commit is contained in:
Mattias Jernberg 2019-07-08 12:15:59 +02:00
parent fd53472238
commit d969f8621d

View File

@ -59,7 +59,8 @@ protected:
payload = msg.payload; payload = msg.payload;
} }
::syslog(syslog_prio_from_level(msg), "%s", payload.data()); int length = std::min<std::common_type<int, std::size_t>::type>(std::numeric_limits<int>::max(), payload.size());
::syslog(syslog_prio_from_level(msg), "%.*s", length, payload.data());
} }
void flush_() override {} void flush_() override {}