trezor: fix potential use of uninitialized memory

CID 1446575
This commit is contained in:
moneromooo-monero 2021-06-11 07:11:23 +00:00
parent 7499837a6f
commit 7b6d959596
No known key found for this signature in database
GPG key ID: 686F07454D6CEFC3

View file

@ -573,8 +573,13 @@ namespace trezor{
std::string req = "PINGPING"; std::string req = "PINGPING";
char res[8]; char res[8];
m_socket->send_to(boost::asio::buffer(req.c_str(), req.size()), m_endpoint); const auto written = m_socket->send_to(boost::asio::buffer(req.c_str(), req.size()), m_endpoint);
receive(res, 8, nullptr, false, timeout); if (written != req.size())
return false;
memset(res, 0, sizeof(res));
const auto received = receive(res, 8, nullptr, false, timeout);
if (received != 8)
return false;
return memcmp(res, "PONGPONG", 8) == 0; return memcmp(res, "PONGPONG", 8) == 0;