diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2021-06-11 07:11:23 +0000 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2021-06-11 07:11:23 +0000 |
commit | 7b6d959596575d51107d5a791f21af8fd4737f92 (patch) | |
tree | d4ba5b72f0dba32a36bf8b3130bfa099a50cf777 /src | |
parent | Merge pull request #7661 (diff) | |
download | monero-7b6d959596575d51107d5a791f21af8fd4737f92.tar.xz |
trezor: fix potential use of uninitialized memory
CID 1446575
Diffstat (limited to 'src')
-rw-r--r-- | src/device_trezor/trezor/transport.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/device_trezor/trezor/transport.cpp b/src/device_trezor/trezor/transport.cpp index 194176413..7a79d8f95 100644 --- a/src/device_trezor/trezor/transport.cpp +++ b/src/device_trezor/trezor/transport.cpp @@ -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; |