mirror of
https://github.com/trussed-dev/usbd-ccid.git
synced 2026-06-20 04:16:20 -07:00
Fix panic when running on x86_64
The length of usize::to_be_bytes depends on the size of the pointer on the targeted cpu architecture
This commit is contained in:
+6
-2
@@ -1,4 +1,4 @@
|
||||
use core::convert::TryInto;
|
||||
use core::convert::{TryFrom, TryInto};
|
||||
|
||||
use crate::constants::*;
|
||||
|
||||
@@ -119,7 +119,11 @@ impl From<DataBlock<'_>> for RawPacket {
|
||||
let len = block.data.len();
|
||||
packet.resize_default(10 + len).ok();
|
||||
packet[0] = 0x80;
|
||||
packet[1..][..4].copy_from_slice(&len.to_le_bytes());
|
||||
packet[1..][..4].copy_from_slice(
|
||||
&u32::try_from(len)
|
||||
.expect("Packets should not be more than 4GiB")
|
||||
.to_le_bytes(),
|
||||
);
|
||||
packet[5] = 0;
|
||||
packet[6] = block.seq;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user