Skip to content

Commit 258cf44

Browse files
committed
Add out-of-range check for literal/length values
This resolves RazrFalcon/usvg#20
1 parent fe4d5e0 commit 258cf44

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/deflate/symbol.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,11 @@ impl Decoder {
203203
match decoded {
204204
0...255 => Symbol::Literal(decoded as u8),
205205
256 => Symbol::EndOfBlock,
206+
286 | 287 => {
207+
let message = format!("The value {} must not occur in compressed data", decoded);
208+
reader.set_last_error(io::Error::new(io::ErrorKind::InvalidData, message));
209+
Symbol::EndOfBlock // dummy value
210+
}
206211
length_code => {
207212
let (base, extra_bits) =
208213
unsafe { *LENGTH_TABLE.get_unchecked(length_code as usize - 257) };

0 commit comments

Comments
 (0)