Fix capacity overflow in JpegReader
This commit is contained in:
1 parent
4dea7c4c81
commit
8fa175c371
2 files changed
+6
No files matched your search
@@ -458,6 +458,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()?;
|
||||||
@@ -511,6 +512,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;
|
||||||
|
|||||||
@@ -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,
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user