mirror of
https://github.com/reactos/reactos.git
synced 2024-10-02 07:26:47 +00:00
[NTOSKRNL_VISTA]
Bug fixes to FsRtlRemoveDotsFromPath() (buffer overrun, buffer underrun, etc.). This fixes the failing test svn path=/trunk/; revision=71047
This commit is contained in:
parent
ef0b98d6fb
commit
de0bb0d228
|
@ -16,7 +16,7 @@ FsRtlRemoveDotsFromPath(IN PWSTR OriginalString,
|
||||||
IN USHORT PathLength,
|
IN USHORT PathLength,
|
||||||
OUT USHORT *NewLength)
|
OUT USHORT *NewLength)
|
||||||
{
|
{
|
||||||
USHORT Length, ReadPos, WritePos = 0;
|
USHORT Length, ReadPos, WritePos;
|
||||||
|
|
||||||
Length = PathLength / sizeof(WCHAR);
|
Length = PathLength / sizeof(WCHAR);
|
||||||
|
|
||||||
|
@ -35,13 +35,9 @@ FsRtlRemoveDotsFromPath(IN PWSTR OriginalString,
|
||||||
return STATUS_IO_REPARSE_DATA_INVALID;
|
return STATUS_IO_REPARSE_DATA_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Length > 0)
|
for (ReadPos = 0, WritePos = 0; ReadPos < Length; ++WritePos)
|
||||||
{
|
{
|
||||||
ReadPos = 0;
|
for (; ReadPos > 0 && ReadPos < Length; ++ReadPos)
|
||||||
|
|
||||||
for (; ReadPos < Length; ++WritePos)
|
|
||||||
{
|
|
||||||
for (; ReadPos < Length; ++ReadPos)
|
|
||||||
{
|
{
|
||||||
if (ReadPos < Length - 1 && OriginalString[ReadPos] == '\\' && OriginalString[ReadPos + 1] == '\\')
|
if (ReadPos < Length - 1 && OriginalString[ReadPos] == '\\' && OriginalString[ReadPos + 1] == '\\')
|
||||||
{
|
{
|
||||||
|
@ -105,10 +101,14 @@ FsRtlRemoveDotsFromPath(IN PWSTR OriginalString,
|
||||||
++ReadPos;
|
++ReadPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ReadPos >= Length)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
OriginalString[WritePos] = OriginalString[ReadPos];
|
OriginalString[WritePos] = OriginalString[ReadPos];
|
||||||
++ReadPos;
|
++ReadPos;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
*NewLength = WritePos * sizeof(WCHAR);
|
*NewLength = WritePos * sizeof(WCHAR);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue