Skip to content

Commit

Permalink
Add check for ID length during decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
ClementNerma committed Aug 22, 2024
1 parent 8644c39 commit 206867b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ impl TrashItemInfos {
.decode(&trash_filename[circumflex_pos + NAME_ID_SEPARATOR.len()..])
.map_err(|_| TrashItemDecodingError::BadlyEncodedId)?;

if id.is_empty() || id.len() > 16 {
return Err(TrashItemDecodingError::InvalidIdLength);
}

let mut int_bytes = [0u8; 16];
int_bytes[16 - id.len()..16].copy_from_slice(&id);

Expand Down

0 comments on commit 206867b

Please sign in to comment.