1From 52f520db6cda25f18e26208745f1b92803d5d559 Mon Sep 17 00:00:00 2001 2From: Albert Astals Cid <aacid@kde.org> 3Date: Tue, 28 May 2019 19:35:18 +0200 4Subject: [PATCH 2/2] Make sure nSelectors is not out of range 5 6nSelectors is used in a loop from 0 to nSelectors to access selectorMtf 7which is 8 UChar selectorMtf[BZ_MAX_SELECTORS]; 9so if nSelectors is bigger than BZ_MAX_SELECTORS it'll do an invalid memory 10access 11 12Fixes out of bounds access discovered while fuzzying karchive 13--- 14 decompress.c | 2 +- 15 1 file changed, 1 insertion(+), 1 deletion(-) 16 17diff --git a/decompress.c b/decompress.c 18index a1a0bac..e1fabdb 100644 19--- a/decompress.c 20+++ b/decompress.c 21@@ -287,7 +287,7 @@ Int32 BZ2_decompress ( DState* s ) 22 GET_BITS(BZ_X_SELECTOR_1, nGroups, 3); 23 if (nGroups < 2 || nGroups > BZ_N_GROUPS) RETURN(BZ_DATA_ERROR); 24 GET_BITS(BZ_X_SELECTOR_2, nSelectors, 15); 25- if (nSelectors < 1) RETURN(BZ_DATA_ERROR); 26+ if (nSelectors < 1 || nSelectors > BZ_MAX_SELECTORS) RETURN(BZ_DATA_ERROR); 27 for (i = 0; i < nSelectors; i++) { 28 j = 0; 29 while (True) { 30-- 311.8.3.1 32 33