mirror of
https://github.com/reactos/reactos.git
synced 2025-07-30 23:12:04 +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:
parent
b6b380a67b
commit
d58e76d5dc
1 changed files with 15 additions and 1 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue