Skip to content

Commit

Permalink
Add out-of-range check for literal/length values
Browse files Browse the repository at this point in the history
This resolves RazrFalcon/usvg#20
  • Loading branch information
sile committed Jul 1, 2018
1 parent fe4d5e0 commit 258cf44
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/deflate/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,11 @@ impl Decoder {
match decoded {
0...255 => Symbol::Literal(decoded as u8),
256 => Symbol::EndOfBlock,
286 | 287 => {
let message = format!("The value {} must not occur in compressed data", decoded);
reader.set_last_error(io::Error::new(io::ErrorKind::InvalidData, message));
Symbol::EndOfBlock // dummy value
}
length_code => {
let (base, extra_bits) =
unsafe { *LENGTH_TABLE.get_unchecked(length_code as usize - 257) };
Expand Down

0 comments on commit 258cf44

Please sign in to comment.