mirror of
https://codeberg.org/demostf/parser.git
synced 2026-06-03 18:24:05 +02:00
additional hardening against mallformed demos
This commit is contained in:
parent
968cc80bee
commit
a7a46384ce
4 changed files with 45 additions and 9 deletions
|
|
@ -297,6 +297,9 @@ impl Parse<'_> for PacketEntitiesMessage {
|
|||
for _ in 0..updated_entries {
|
||||
let diff: u32 = read_bit_var(&mut data)?;
|
||||
last_index = last_index.saturating_add(diff as i32).saturating_add(1);
|
||||
if last_index >= 2048 {
|
||||
return Err(ParseError::InvalidDemo("invalid entity index"));
|
||||
}
|
||||
let entity_index = EntityId::from(last_index as u32);
|
||||
|
||||
let update_type = data.read()?;
|
||||
|
|
|
|||
|
|
@ -414,7 +414,7 @@ pub fn parse_string_table_update<'a>(
|
|||
|
||||
for _ in 0..entry_count {
|
||||
let index = if stream.read()? {
|
||||
(last_entry + 1) as u16
|
||||
last_entry.saturating_add(1) as u16
|
||||
} else {
|
||||
stream.read_sized(entry_bits as usize)?
|
||||
};
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ impl Parse<'_> for TempEntitiesMessage {
|
|||
|
||||
let class_id = if stream.read()? {
|
||||
let bits = log_base2(state.server_classes.len()) + 1;
|
||||
(stream.read_sized::<u16>(bits as usize)? - 1).into()
|
||||
(stream.read_sized::<u16>(bits as usize)?.saturating_sub(1)).into()
|
||||
} else {
|
||||
let last = events.last().ok_or(ParseError::InvalidDemo(
|
||||
"temp entity update without previous",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue