trezor: fix potential use of uninitialized memory

CID 1446575
pull/7752/head
moneromooo-monero 3 years ago
parent 7499837a6f
commit 7b6d959596
No known key found for this signature in database
GPG Key ID: 686F07454D6CEFC3

@ -573,8 +573,13 @@ namespace trezor{
std::string req = "PINGPING";
char res[8];
m_socket->send_to(boost::asio::buffer(req.c_str(), req.size()), m_endpoint);
receive(res, 8, nullptr, false, timeout);
const auto written = m_socket->send_to(boost::asio::buffer(req.c_str(), req.size()), m_endpoint);
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;

Loading…
Cancel
Save