mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-09-01 19:26:16 +00:00
[RTL]
Fix a mistake in RtlNumberOfSetBits, check for index out of range in RtlFindNextForwardRun* svn path=/trunk/; revision=56794
This commit is contained in:
@@ -421,7 +421,7 @@ RtlNumberOfSetBits(
|
||||
}
|
||||
|
||||
Shift = 8 - (BitMapHeader->SizeOfBitMap & 7);
|
||||
BitCount += BitCountTable[(*Byte) << Shift];
|
||||
BitCount += BitCountTable[((*Byte) << Shift) & 0xFF];
|
||||
|
||||
return BitCount;
|
||||
}
|
||||
@@ -618,6 +618,13 @@ RtlFindNextForwardRunClear(
|
||||
{
|
||||
ULONG Length;
|
||||
|
||||
/* Check for buffer overrun */
|
||||
if (FromIndex >= BitMapHeader->SizeOfBitMap)
|
||||
{
|
||||
*StartingRunIndex = FromIndex;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Assume a set run first, count it's length */
|
||||
Length = RtlpGetLengthOfRunSet(BitMapHeader, FromIndex, MAXULONG);
|
||||
*StartingRunIndex = FromIndex + Length;
|
||||
@@ -635,6 +642,13 @@ RtlFindNextForwardRunSet(
|
||||
{
|
||||
ULONG Length;
|
||||
|
||||
/* Check for buffer overrun */
|
||||
if (FromIndex >= BitMapHeader->SizeOfBitMap)
|
||||
{
|
||||
*StartingRunIndex = FromIndex;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Assume a clear run first, count it's length */
|
||||
Length = RtlpGetLengthOfRunClear(BitMapHeader, FromIndex, MAXULONG);
|
||||
*StartingRunIndex = FromIndex + Length;
|
||||
|
||||
Reference in New Issue
Block a user