Fix out of bounds subtraction with invalid JPEG table

This commit is contained in:
5225225 committed 2021-05-29 22:12:35 +01:00
1 parent 5b7814c994
commit 03b6ed413b
3 files changed
+43 -1

No files matched your search

+6
View File
@@ -225,6 +225,12 @@ impl JpegReader {
match jpeg_tables {
Some(tables) => {
assert!(
tables.len() >= 2,
"jpeg_tables, if given, must be at least 2 bytes long. Got {:?}",
tables
);
let mut jpeg_data = tables.clone();
let truncated_length = jpeg_data.len() - 2;
jpeg_data.truncate(truncated_length);