1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-10 15:04:32 +03:00

avoid OOM with unreasonable sixel data

refs: https://github.com/wez/wezterm/issues/1610
This commit is contained in:
Wez Furlong 2022-02-01 22:16:02 -07:00
parent 9de0e1ac90
commit 519cf58526

View File

@ -9,6 +9,18 @@ use termwiz::image::ImageDataType;
impl TerminalState {
pub(crate) fn sixel(&mut self, sixel: Box<Sixel>) {
let (width, height) = sixel.dimensions();
const MAX_IMAGE_SIZE: u32 = 100_000_000;
let size = width.saturating_mul(height).saturating_mul(4);
if size > MAX_IMAGE_SIZE {
log::error!(
"Ignoring sixel image data {}x{} because {} bytes > max allowed {}",
width,
height,
size,
MAX_IMAGE_SIZE
);
return;
}
let mut private_color_map;
let color_map = if self.use_private_color_registers_for_each_graphic {