mirror of
https://github.com/torvalds/linux.git
synced 2026-10-07 05:31:08 -04:00
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]>
This commit is contained in:
1 parent
528941ca05
commit
eb0cf3e19b
1 file changed
+3
@@ -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;
|
||||
}
|
||||
|
||||
len += LZMA_MATCH_MIN_LEN;
|
||||
|
||||
Reference in new issue
Block a user