aboutsummaryrefslogtreecommitdiff
path: root/src/device_trezor
diff options
context:
space:
mode:
Diffstat (limited to 'src/device_trezor')
-rw-r--r--src/device_trezor/trezor/protocol.hpp4
-rw-r--r--src/device_trezor/trezor/transport.cpp9
2 files changed, 8 insertions, 5 deletions
diff --git a/src/device_trezor/trezor/protocol.hpp b/src/device_trezor/trezor/protocol.hpp
index fa824ec3b..0fdd36a51 100644
--- a/src/device_trezor/trezor/protocol.hpp
+++ b/src/device_trezor/trezor/protocol.hpp
@@ -66,9 +66,7 @@ namespace protocol{
template<typename T>
bool cn_deserialize(const void * buff, size_t len, T & dst){
- std::stringstream ss;
- ss.write(static_cast<const char *>(buff), len); //ss << tx_blob;
- binary_archive<false> ba(ss);
+ binary_archive<false> ba{{reinterpret_cast<const std::uint8_t*>(buff), len}};
bool r = ::serialization::serialize(ba, dst);
return r;
}
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;