Skip to contentSkip to conversation

lz4: ensure length does not wrap

PATCH Applied Holger Schurig 1 participant 1 message Jul 1, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 2/3 lz4: ensure length does not wrap

Note: this is the same as 206204a1162b995e2185275167b22468c00d6b36 in linux-git.

Given some pathologically compressed data, lz4 could possibly decide to wrap a few internal variables, causing unknown things to happen. Catch this before the wrapping happens and abort the decompression.

---
 lib/lz4/lz4_decompress.c | 2 ++
 1 file changed, 2 insertions(+)
lib/lz4/lz4_decompress.c +2 -0
index 8e64ce6..75cf08b 100644
@@ -73,6 +73,8 @@ static int lz4_uncompress(const char *source, char *dest, int osize)
 			len = *ip++;
 			for (; len == 255; length += 255)
 				len = *ip++;
+			if (unlikely(length > (size_t)(length + len)))
+				goto _output_error;
 			length += len;
 		}
 
Signature · 7 lines
1.8.5.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox