diff --git a/crates/ironrdp-cliprdr-format/src/bitmap.rs b/crates/ironrdp-cliprdr-format/src/bitmap.rs index c5d41faf..7f65e124 100644 --- a/crates/ironrdp-cliprdr-format/src/bitmap.rs +++ b/crates/ironrdp-cliprdr-format/src/bitmap.rs @@ -703,7 +703,12 @@ fn decode_png(mut input: &[u8]) -> Result<(png::OutputInfo, Vec), BitmapErro decoder.set_transformations(png::Transformations::ALPHA | png::Transformations::EXPAND); let mut reader = decoder.read_info()?; - let mut buffer = vec![0; reader.output_buffer_size()]; + let output_buffer_len = reader.output_buffer_size(); + + // Prevent allocation of huge buffers. + ensure(output_buffer_len <= MAX_BUFFER_SIZE).ok_or(BitmapError::BufferTooBig)?; + + let mut buffer = vec![0; output_buffer_len]; let info = reader.next_frame(&mut buffer)?; buffer.truncate(info.buffer_size()); diff --git a/crates/ironrdp-testsuite-core/test_data/fuzz_regression/cliprdr_format/minimized-from-a587e617baf5354b27cf9e6cbe92dc5d1b5cab7b b/crates/ironrdp-testsuite-core/test_data/fuzz_regression/cliprdr_format/minimized-from-a587e617baf5354b27cf9e6cbe92dc5d1b5cab7b new file mode 100644 index 00000000..901b5076 Binary files /dev/null and b/crates/ironrdp-testsuite-core/test_data/fuzz_regression/cliprdr_format/minimized-from-a587e617baf5354b27cf9e6cbe92dc5d1b5cab7b differ