Fix name length handing in RtlQueryAtomInAtomTable.

svn path=/trunk/; revision=16999
This commit is contained in:
Filip Navara 2005-08-03 14:45:39 +00:00
parent 1eaff64466
commit e51757630c

View file

@ -602,19 +602,10 @@ RtlQueryAtomInAtomTable(PRTL_ATOM_TABLE AtomTable,
if (*NameLength < Length + sizeof(WCHAR)) if (*NameLength < Length + sizeof(WCHAR))
{ {
/* prevent underflow! */ *NameLength = Length;
if (*NameLength >= sizeof(WCHAR))
{
Length = *NameLength - sizeof(WCHAR);
}
else
{
Length = 0;
Status = STATUS_BUFFER_TOO_SMALL; Status = STATUS_BUFFER_TOO_SMALL;
} }
} else
if (Length)
{ {
RtlCopyMemory(AtomName, RtlCopyMemory(AtomName,
NameString, NameString,
@ -652,19 +643,10 @@ RtlQueryAtomInAtomTable(PRTL_ATOM_TABLE AtomTable,
if (*NameLength < Length + sizeof(WCHAR)) if (*NameLength < Length + sizeof(WCHAR))
{ {
/* prevent underflow! */ *NameLength = Length;
if (*NameLength >= sizeof(WCHAR))
{
Length = *NameLength - sizeof(WCHAR);
}
else
{
Length = 0;
Status = STATUS_BUFFER_TOO_SMALL; Status = STATUS_BUFFER_TOO_SMALL;
} }
} else
if (Length)
{ {
RtlCopyMemory(AtomName, RtlCopyMemory(AtomName,
Entry->Name, Entry->Name,