Skip to content

Commit eb0cf3e

Browse files
Larhzutorvalds
authored andcommitted
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: Lasse Collin <[email protected]> Cc: "H. Peter Anvin" <[email protected]> Cc: Alain Knaff <[email protected]> Cc: Albin Tonnerre <[email protected]> Cc: Phillip Lougher <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 528941c commit eb0cf3e

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

lib/decompress_unlzma.c

+3
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,9 @@ static inline int INIT process_bit1(struct writer *wr, struct rc *rc,
522522
cst->rep0 = pos_slot;
523523
if (++(cst->rep0) == 0)
524524
return 0;
525+
if (cst->rep0 > wr->header->dict_size
526+
|| cst->rep0 > get_pos(wr))
527+
return -1;
525528
}
526529

527530
len += LZMA_MATCH_MIN_LEN;

0 commit comments

Comments
 (0)