Skip to content

Commit 0db79d4

Browse files
committed
[NTOSKRNL:FSRTL] Fix memory corruption when pruning tunnel cache
1 parent 3ec3e1a commit 0db79d4

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

ntoskrnl/fsrtl/tunnel.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ FsRtlFreeTunnelNode(
4242
{
4343
if (PoolList)
4444
{
45-
/* divert the linked list entry, it's not required anymore, but we need it */
45+
/* divert the linked list entry, it's not required anymore, but we need it */
4646
InsertHeadList(PoolList, &CurEntry->TimerQueueEntry);
4747
return;
4848
}
@@ -124,7 +124,8 @@ FsRtlPruneTunnelCache(
124124
/* If we have too many entries */
125125
while (Cache->NumEntries > TunnelMaxEntries)
126126
{
127-
CurEntry = CONTAINING_RECORD(Entry, TUNNEL_NODE_ENTRY, TimerQueueEntry);
127+
ASSERT(!IsListEmpty(&Cache->TimerQueue));
128+
CurEntry = CONTAINING_RECORD(Cache->TimerQueue.Flink, TUNNEL_NODE_ENTRY, TimerQueueEntry);
128129
FsRtlRemoveNodeFromTunnel(Cache, CurEntry, PoolList, &Rebalance);
129130
}
130131
}
@@ -477,7 +478,7 @@ FsRtlAddToTunnelCache(IN PTUNNEL Cache,
477478
RtlInsertAsRightChild(RtlParent(CurEntry), NodeEntry);
478479
}
479480
}
480-
481+
481482
/* remove entry */
482483
RemoveEntryList(&((PTUNNEL_NODE_ENTRY)CurEntry)->TimerQueueEntry);
483484

0 commit comments

Comments
 (0)