Merge pull request #918 from Morilli/fix-bzip2-selector-oob

[bzip2] fix possible out of bounds access due to unsanitized nSelectors usage
This commit is contained in:
Adam Hathcock
2025-06-03 08:11:55 +01:00
committed by GitHub

View File

@@ -542,9 +542,14 @@ internal class CBZip2InputStream : Stream
{
j++;
}
selectorMtf[i] = (char)j;
if (i < BZip2Constants.MAX_SELECTORS)
{
selectorMtf[i] = (char)j;
}
}
nSelectors = Math.Min(nSelectors, BZip2Constants.MAX_SELECTORS);
/* Undo the MTF values for the selectors. */
{
var pos = new char[BZip2Constants.N_GROUPS];