Fixed null characters in print_hosts output

This commit is contained in:
SChernykh 2023-06-29 09:09:02 +02:00
parent f79be1b343
commit 375bf56e2e
2 changed files with 9 additions and 3 deletions

View file

@ -146,7 +146,13 @@ COLOR_ENTRY(LightCyan, "\x1b[0;96m")
template<size_t N> struct Stream::Entry<char[N]>
{
static FORCEINLINE void put(const char (&data)[N], Stream* wrapper) { wrapper->writeBuf(data, N - 1); }
template<typename T>
// cppcheck-suppress constParameterReference
static FORCEINLINE void put(T (&data)[N], Stream* wrapper)
{
static_assert(std::is_same<T, const char>::value, "Non-const char buffer must be cast to \"const char*\"");
wrapper->writeBuf(data, N - 1);
}
};
template<> struct Stream::Entry<const char*>

View file

@ -234,10 +234,10 @@ void p2pool::print_hosts() const
}
if (h.m_displayName == host.m_displayName) {
LOGINFO(0, log::LightCyan() << "-> " << h.m_displayName << buf);
LOGINFO(0, log::LightCyan() << "-> " << h.m_displayName << static_cast<const char*>(buf));
}
else {
LOGINFO(0, " " << h.m_displayName << buf);
LOGINFO(0, " " << h.m_displayName << static_cast<const char*>(buf));
}
}
}