Skip to content

Commit 11c73f2

Browse files
committed
run_len_dist: validate that dist is not 0. Fixes information disclosure vulnerability in this function. This is not exploitable in practice, because run_len_dist() is not exposes in the public API and is never called with dist=0 from this crate, even given deliberately malformed inputs.
1 parent 3715c4c commit 11c73f2

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,9 @@ impl InflateStream {
625625
fn run_len_dist(&mut self, len: u16, dist: u16) -> Result<Option<u16>, String> {
626626
debug!("RLE -{}; {} (cap={} len={})", dist, len,
627627
self.buffer.capacity(), self.buffer.len());
628+
if dist < 1 {
629+
return Err("invalid run length in stream".to_owned());
630+
}
628631
let buffer_size = self.buffer.capacity() as u16;
629632
let len = if self.pos < dist {
630633
// Handle copying from ahead, until we hit the end reading.

0 commit comments

Comments
 (0)