Commit eb0cf3e1 authored by Lasse Collin's avatar Lasse Collin Committed by Linus Torvalds

Decompressors: validate match distance in decompress_unlzma.c

Validate the newly decoded distance (rep0) in process_bit1().  This is to
detect corrupt LZMA data quickly.  The old code can run for long time
producing garbage until it hits the end of the input.
Signed-off-by: default avatarLasse Collin <>
Cc: "H. Peter Anvin" <>
Cc: Alain Knaff <>
Cc: Albin Tonnerre <>
Cc: Phillip Lougher <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent 528941ca
......@@ -522,6 +522,9 @@ static inline int INIT process_bit1(struct writer *wr, struct rc *rc,
cst->rep0 = pos_slot;
if (++(cst->rep0) == 0)
return 0;
if (cst->rep0 > wr->header->dict_size
|| cst->rep0 > get_pos(wr))
return -1;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment