Merge pull request #200 from anfedotoff/master

Fix capacity overflow in JpegReader
This commit is contained in:
Andreas Molzer authored and GitHub committed 2023-02-06 21:22:13 +01:00
commit aa10d27a28
2 files changed
+6

No files matched your search

+4
View File
@@ -466,6 +466,7 @@ impl Image {
output_width: usize, output_width: usize,
byte_order: ByteOrder, byte_order: ByteOrder,
chunk_index: u32, chunk_index: u32,
limits: &Limits,
) -> TiffResult<()> { ) -> TiffResult<()> {
// Validate that the provided buffer is of the expected type. // Validate that the provided buffer is of the expected type.
let color_type = self.colortype()?; let color_type = self.colortype()?;
@@ -520,6 +521,9 @@ impl Image {
.ok_or(TiffError::FormatError( .ok_or(TiffError::FormatError(
TiffFormatError::InconsistentSizesEncountered, TiffFormatError::InconsistentSizesEncountered,
))?; ))?;
if *compressed_bytes > limits.intermediate_buffer_size as u64 {
return Err(TiffError::LimitsExceeded);
}
let byte_len = buffer.byte_len(); let byte_len = buffer.byte_len();
let compression_method = self.compression_method; let compression_method = self.compression_method;
+2
View File
@@ -1042,6 +1042,7 @@ impl<R: Read + Seek> Decoder<R> {
output_width, output_width,
byte_order, byte_order,
chunk_index, chunk_index,
&self.limits,
)?; )?;
Ok(()) Ok(())
@@ -1168,6 +1169,7 @@ impl<R: Read + Seek> Decoder<R> {
width as usize, width as usize,
byte_order, byte_order,
chunk as u32, chunk as u32,
&self.limits,
)?; )?;
} }