mirror of
https://github.com/fossasia/badgemagic-rs
synced 2025-08-14 11:17:59 +00:00
fix: ensure offset cannot be greater than data size
This commit is contained in:
parent
914f1f9a42
commit
9e66a19c8c
1 changed files with 3 additions and 0 deletions
|
@ -128,6 +128,9 @@ 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;
|
||||
if offset > data.len() {
|
||||
return result;
|
||||
}
|
||||
if data.len() - offset < 64 {
|
||||
result[1..].copy_from_slice(&data[offset..]);
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue