mirror of
https://github.com/fossasia/badgemagic-rs
synced 2025-08-14 11:17:59 +00:00
fix: handle data not padded to 64 in helper function
This commit is contained in:
parent
200428dfbe
commit
914f1f9a42
1 changed files with 5 additions and 1 deletions
|
@ -128,6 +128,10 @@ fn write_raw(device: &HidDevice, data: &[u8]) -> Result<()> {
|
|||
fn prepend_byte_and_offset(data: &[u8], offset: usize) -> [u8; 65] {
|
||||
let mut result: [u8; 65] = [0u8; 65];
|
||||
result[1] = 0x0;
|
||||
result[1..].copy_from_slice(&data[offset..offset + 64]);
|
||||
if data.len() - offset < 64 {
|
||||
result[1..].copy_from_slice(&data[offset..]);
|
||||
} else {
|
||||
result[1..].copy_from_slice(&data[offset..offset + 64]);
|
||||
}
|
||||
result
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue