[PATCH] bzip2recover: Make sure to not process more than BZ_MAX_HANDLED_BLOCKS

Mark Wielaard mark@klomp.org
Thu May 28 14:54:07 GMT 2026


There is an off-by-one in the check before calling tooManyBlocks. This
causes the scanning loop to run one more time and cause a possible
read or write one past the global bStart, bEnd, rbStart and rbEnd
buffers. There are no known exploits of this issue and you will need
to compile with something like gcc -fsanitize=address (ASAN
AddressSanitizer) to observe the faulty read/write.

This has been assigned CVE-2026-42250.
---
 bzip2recover.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bzip2recover.c b/bzip2recover.c
index a8131e0611ec..4b1c219034c6 100644
--- a/bzip2recover.c
+++ b/bzip2recover.c
@@ -402,7 +402,7 @@ Int32 main ( Int32 argc, Char** argv )
             rbEnd[rbCtr] = bEnd[currBlock];
             rbCtr++;
          }
-         if (currBlock >= BZ_MAX_HANDLED_BLOCKS)
+         if (currBlock >= BZ_MAX_HANDLED_BLOCKS - 1)
             tooManyBlocks(BZ_MAX_HANDLED_BLOCKS);
          currBlock++;
 
-- 
2.54.0



More information about the Bzip2-devel mailing list