[NTOS:CM] Do not call ZwQueryObject with a zero-size buffer. CORE-15882

Actually fixes ntdll_apitest:NtLoadUnloadKey.
This commit is contained in:
Thomas Faber 2019-05-07 13:51:06 +02:00
parent 627f0242ad
commit f86360fdbc
No known key found for this signature in database
GPG key ID: 076E7C3D44720826
2 changed files with 8 additions and 6 deletions

View file

@ -135,6 +135,7 @@ CmpAddToHiveFileList(IN PCMHIVE Hive)
UNICODE_STRING HivePath;
PWCHAR FilePath;
ULONG Length;
OBJECT_NAME_INFORMATION DummyNameInfo;
POBJECT_NAME_INFORMATION FileNameInfo;
HivePath.Buffer = NULL;
@ -175,10 +176,10 @@ CmpAddToHiveFileList(IN PCMHIVE Hive)
/* Determine the right buffer size and allocate */
Status = ZwQueryObject(Hive->FileHandles[HFILE_TYPE_PRIMARY],
ObjectNameInformation,
NULL,
0,
&DummyNameInfo,
sizeof(DummyNameInfo),
&Length);
if (Status != STATUS_INFO_LENGTH_MISMATCH)
if (Status != STATUS_BUFFER_OVERFLOW)
{
DPRINT1("CmpAddToHiveFileList: Hive file name size query failed, status = 0x%08lx\n", Status);
goto Quickie;

View file

@ -279,6 +279,7 @@ CmpCmdHiveOpen(IN POBJECT_ATTRIBUTES FileAttributes,
UNICODE_STRING FileName;
PWCHAR FilePath;
ULONG Length;
OBJECT_NAME_INFORMATION DummyNameInfo;
POBJECT_NAME_INFORMATION FileNameInfo;
PAGED_CODE();
@ -299,10 +300,10 @@ CmpCmdHiveOpen(IN POBJECT_ATTRIBUTES FileAttributes,
/* Determine the right buffer size and allocate */
Status = ZwQueryObject(FileAttributes->RootDirectory,
ObjectNameInformation,
NULL,
0,
&DummyNameInfo,
sizeof(DummyNameInfo),
&Length);
if (Status != STATUS_INFO_LENGTH_MISMATCH)
if (Status != STATUS_BUFFER_OVERFLOW)
{
DPRINT1("CmpCmdHiveOpen(): Root directory handle object name size query failed, Status = 0x%08lx\n", Status);
return Status;