diff --git a/src/device_trezor/trezor/transport.cpp b/src/device_trezor/trezor/transport.cpp index eb4080081..b6290b7ea 100644 --- a/src/device_trezor/trezor/transport.cpp +++ b/src/device_trezor/trezor/transport.cpp @@ -481,14 +481,14 @@ namespace trezor{ } boost::optional bin_data = m_response->parse_hexstr(); - if (!bin_data){ + if (!bin_data || bin_data->size() < PROTO_HEADER_SIZE){ throw exc::CommunicationException("Response is not well hexcoded"); } uint16_t msg_tag; uint32_t msg_len; deserialize_message_header(bin_data->data(), msg_tag, msg_len); - if (bin_data->size() != msg_len + PROTO_HEADER_SIZE){ + if (bin_data->size() - PROTO_HEADER_SIZE != msg_len){ throw exc::CommunicationException("Response is not well hexcoded"); }