From 9d3949659c360b88fdadad7b5b8becd56d769263 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sosth=C3=A8ne=20Gu=C3=A9don?= Date: Wed, 25 Jan 2023 10:01:58 +0100 Subject: [PATCH] Fix https://github.com/Nitrokey/nitrokey-3-firmware/issues/150 When using highspeed usb, some calculations worked with usb 1 constants. This caused packets to be handled improperly. --- src/pipe.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pipe.rs b/src/pipe.rs index 9a5df4c..216ff60 100644 --- a/src/pipe.rs +++ b/src/pipe.rs @@ -153,10 +153,10 @@ where self.ext_packet.extend_from_slice(&packet).unwrap(); let pl = packet.packet_len(); - if pl > 54 { + if pl > PACKET_SIZE - CCID_HEADER_LEN { self.receiving_long = true; self.in_chain = 1; - self.long_packet_missing = pl - 54; + self.long_packet_missing = pl - PACKET_SIZE - CCID_HEADER_LEN; self.packet_len = pl; return; } else {