1
0
Fork 0
mirror of https://codeberg.org/demostf/parser.git synced 2026-06-03 18:24:05 +02:00

prevent panic on invalid compressed stringtable size

fixes #2
This commit is contained in:
Robin Appelman 2021-05-22 17:35:05 +02:00
commit 4d87f5b279

View file

@ -48,6 +48,12 @@ impl<'a> Parse<'a> for CreateStringTableMessage<'a> {
let decompressed_size: u32 = table_data.read()?; let decompressed_size: u32 = table_data.read()?;
let compressed_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))?; let magic = table_data.read_string(Some(4))?;
if magic != "SNAP" { if magic != "SNAP" {