Skip to content

Commit

Permalink
prevent panic on invalid compressed stringtable size
Browse files Browse the repository at this point in the history
fixes #2
  • Loading branch information
icewind1991 committed May 22, 2021
1 parent e2a631c commit 4d87f5b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/demo/message/stringtable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ impl<'a> Parse<'a> for CreateStringTableMessage<'a> {
let decompressed_size: u32 = table_data.read()?;
let compressed_size: u32 = table_data.read()?;

if compressed_size < 4 {
return Err(ParseError::InvalidDemo(
"Invalid compressed string table size",
));
}

let magic = table_data.read_string(Some(4))?;

if magic != "SNAP" {
Expand Down

0 comments on commit 4d87f5b

Please sign in to comment.