Skip to contentSkip to conversation

Decompressors: Fix header validation in decompress_unlzma.c

PATCH New Lasse Collin 1 participant 1 message Nov 23, 2010 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 Decompressors: Fix header validation in decompress_unlzma.c

From: Lasse Collin <[email protected]>

Validation of header.pos calls error() but doesn't make the function return to indicate an error to the caller. Instead the decoding is attempted with invalid header.pos. This fixes it.

---

lib/decompress_unlzma.c renamed from lib/decompress_unlzma.c.orig +3 -1
@@ -580,8 +580,10 @@ STATIC inline int INIT unlzma(unsigned c
 		((unsigned char *)&header)[i] = *rc.ptr++;
 	}
 
-	if (header.pos >= (9 * 5 * 5))
+	if (header.pos >= (9 * 5 * 5)) {
 		error("bad header");
+		goto exit_1;
+	}
 
 	mi = 0;
 	lc = header.pos;