diff options
| author | Szczepan Zalega <szczepan@nitrokey.com> | 2016-08-05 20:59:50 +0200 | 
|---|---|---|
| committer | Szczepan Zalega <szczepan@nitrokey.com> | 2016-08-05 21:56:07 +0200 | 
| commit | caf500394b7ba674e2fff834f2d170a0f0a909a4 (patch) | |
| tree | 2508357c2a88f0d44a483ee9801909b72a162753 | |
| parent | b9b6eb6d618915a8ee693e345448d2bcd39779cc (diff) | |
| download | libnitrokey-caf500394b7ba674e2fff834f2d170a0f0a909a4.tar.gz libnitrokey-caf500394b7ba674e2fff834f2d170a0f0a909a4.tar.bz2 | |
Clear outgoing packet as soon as command response is received
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
| -rw-r--r-- | include/device_proto.h | 10 | 
1 files changed, 9 insertions, 1 deletions
| 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 <typename T> +    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 ") + | 
