[NTOS:CM] In CmpParseKey(), do not assert but instead correctly return failure if CmpHandleExitNode() doesn't return a valid node, or CmpCreateKeyControlBlock() fails.

This commit is contained in:
Hermès Bélusca-Maïto 2019-04-22 21:09:10 +02:00
parent 627b1df579
commit 884db2ea06
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0

View file

@ -960,7 +960,7 @@ CmpHandleExitNode(IN OUT PHHIVE *Hive,
{ {
/* Release it */ /* Release it */
ASSERT(*ReleaseHive != NULL); ASSERT(*ReleaseHive != NULL);
HvReleaseCell((*ReleaseHive), *ReleaseCell); HvReleaseCell(*ReleaseHive, *ReleaseCell);
} }
/* Get the link references */ /* Get the link references */
@ -968,7 +968,7 @@ CmpHandleExitNode(IN OUT PHHIVE *Hive,
*Cell = (*KeyNode)->ChildHiveReference.KeyCell; *Cell = (*KeyNode)->ChildHiveReference.KeyCell;
/* Get the new node */ /* Get the new node */
*KeyNode = (PCM_KEY_NODE)HvGetCell((*Hive), *Cell); *KeyNode = (PCM_KEY_NODE)HvGetCell(*Hive, *Cell);
if (*KeyNode) if (*KeyNode)
{ {
/* Set the new release values */ /* Set the new release values */
@ -1191,7 +1191,12 @@ CmpParseKey(IN PVOID ParseObject,
&Node, &Node,
&HiveToRelease, &HiveToRelease,
&CellToRelease); &CellToRelease);
if (!Node) ASSERT(FALSE); if (!Node)
{
/* Fail */
Status = STATUS_INSUFFICIENT_RESOURCES;
break;
}
} }
/* Do the open */ /* Do the open */
@ -1232,7 +1237,12 @@ CmpParseKey(IN PVOID ParseObject,
&Node, &Node,
&HiveToRelease, &HiveToRelease,
&CellToRelease); &CellToRelease);
if (!Node) ASSERT(FALSE); if (!Node)
{
/* Fail */
Status = STATUS_INSUFFICIENT_RESOURCES;
break;
}
} }
/* Create a KCB for this key */ /* Create a KCB for this key */
@ -1242,7 +1252,12 @@ CmpParseKey(IN PVOID ParseObject,
ParentKcb, ParentKcb,
0, 0,
&NextName); &NextName);
if (!Kcb) ASSERT(FALSE); if (!Kcb)
{
/* Fail */
Status = STATUS_INSUFFICIENT_RESOURCES;
break;
}
/* Dereference the parent and set the new one */ /* Dereference the parent and set the new one */
CmpDereferenceKeyControlBlock(ParentKcb); CmpDereferenceKeyControlBlock(ParentKcb);
@ -1353,7 +1368,12 @@ CmpParseKey(IN PVOID ParseObject,
&Node, &Node,
&HiveToRelease, &HiveToRelease,
&CellToRelease); &CellToRelease);
if (!Node) ASSERT(FALSE); if (!Node)
{
/* Fail */
Status = STATUS_INSUFFICIENT_RESOURCES;
break;
}
} }
/* Do the open */ /* Do the open */
@ -1386,7 +1406,8 @@ CmpParseKey(IN PVOID ParseObject,
/* Dereference the parent if it exists */ /* Dereference the parent if it exists */
Quickie: Quickie:
if (ParentKcb) CmpDereferenceKeyControlBlock(ParentKcb); if (ParentKcb)
CmpDereferenceKeyControlBlock(ParentKcb);
/* Unlock the registry */ /* Unlock the registry */
CmpUnlockRegistry(); CmpUnlockRegistry();