Skip to contentSkip to conversation

Decompressors: validate match distance in unlzma.c

PATCH In review Jan Beulich 1 participant 1 message Nov 11, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 7/9 Decompressors: validate match distance in unlzma.c

From: Lasse Collin <[email protected]>

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.

xen/common/unlzma.c +3 -0
@@ -516,6 +516,9 @@ static inline int INIT process_bit1(stru
 			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;

Decompressors: validate match distance in unlzma.c

From: Lasse Collin <[email protected]>

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.

xen/common/unlzma.c +3 -0
@@ -516,6 +516,9 @@ static inline int INIT process_bit1(stru
 			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;

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel