Use snprintf instead of sprintf (ref #4361)

This commit is contained in:
Artem Pavlenko 2022-11-04 13:46:10 +00:00
parent 5522cdd201
commit 7e5655eef4

View file

@ -51,7 +51,7 @@ std::string to_hex(const char* blob, std::size_t size)
std::memset(hex, 0, 3); std::memset(hex, 0, 3);
for (std::size_t pos = 0; pos < size; ++pos) for (std::size_t pos = 0; pos < size; ++pos)
{ {
std::sprintf(hex, "%02x", int(blob[pos]) & 0xff); std::snprintf(hex, 3, "%02x", int(blob[pos]) & 0xff);
s << hex; s << hex;
} }
return s.str(); return s.str();