fix: handle data not padded to 64 in helper function

This commit is contained in:
RedCommander735 2025-07-27 04:45:38 +02:00
parent 200428dfbe
commit 914f1f9a42

View file

@ -128,6 +128,10 @@ fn write_raw(device: &HidDevice, data: &[u8]) -> Result<()> {
fn prepend_byte_and_offset(data: &[u8], offset: usize) -> [u8; 65] { fn prepend_byte_and_offset(data: &[u8], offset: usize) -> [u8; 65] {
let mut result: [u8; 65] = [0u8; 65]; let mut result: [u8; 65] = [0u8; 65];
result[1] = 0x0; result[1] = 0x0;
if data.len() - offset < 64 {
result[1..].copy_from_slice(&data[offset..]);
} else {
result[1..].copy_from_slice(&data[offset..offset + 64]); result[1..].copy_from_slice(&data[offset..offset + 64]);
}
result result
} }