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

harden against dos with crafted input by limiting reserved vec/map size

This commit is contained in:
Robin Appelman 2020-01-19 22:13:12 +01:00
commit 3caadadb3b
7 changed files with 14 additions and 7 deletions

View file

@ -7,6 +7,7 @@ use crate::demo::packet::stringtable::{
};
use crate::demo::parser::ParseBitSkip;
use crate::{Parse, ParseError, ParserState, ReadResult, Result, Stream};
use std::cmp::min;
#[derive(Debug)]
pub struct CreateStringTableMessage {
@ -149,7 +150,7 @@ struct TableEntries {
impl TableEntries {
pub fn new(count: usize) -> Self {
TableEntries {
entries: Vec::with_capacity(count),
entries: Vec::with_capacity(min(count, 128)),
history: Vec::with_capacity(32),
}
}