From caf500394b7ba674e2fff834f2d170a0f0a909a4 Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Fri, 5 Aug 2016 20:59:50 +0200 Subject: Clear outgoing packet as soon as command response is received Signed-off-by: Szczepan Zalega --- include/device_proto.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/include/device_proto.h b/include/device_proto.h index 78abe38..f28b5b9 100644 --- a/include/device_proto.h +++ b/include/device_proto.h @@ -161,7 +161,13 @@ class Transaction : semantics::non_constructible { return outp.crc; } - static response_payload run(device::Device &dev, + template + static void clear_packet(T &st){ + bzero(&st, sizeof(st)); + } + + + static response_payload run(device::Device &dev, const command_payload &payload) { using namespace ::nitrokey::device; using namespace ::nitrokey::log; @@ -208,6 +214,8 @@ class Transaction : semantics::non_constructible { std::this_thread::sleep_for(dev.get_retry_timeout()); continue; } + clear_packet(outp); + if (status <= 0) throw std::runtime_error( std::string("Device error while executing command ") + -- cgit v1.2.3