[NTOSKRNL] Unify buffer size calculation in FsRtlIs{Name,Dbcs}InExpression

It better captures the intent now in FsRtlIsNameInExpressionPrivate and
fixes a slight overallotion by 4 bytes in FsRtlIsDbcsInExpression.

While at it, use the ANSI_DOS_DOT macro in the Dbcs version.

CORE-15902
This commit is contained in:
Bartosz Brachaczek 2019-04-01 01:58:21 +02:00 committed by Pierre Schweitzer
parent 6eadbfb7e7
commit 695e00fbbd
No known key found for this signature in database
GPG key ID: 7545556C3D585B0B
2 changed files with 3 additions and 3 deletions

View file

@ -291,7 +291,7 @@ FsRtlIsDbcsInExpression(IN PANSI_STRING Expression,
ASSERT((OldBackTracking == BackTrackingBuffer) || (OldBackTracking == OldBackTrackingBuffer)); ASSERT((OldBackTracking == BackTrackingBuffer) || (OldBackTracking == OldBackTrackingBuffer));
/* Calculate buffer size */ /* Calculate buffer size */
BackTrackingBufferSize = (Expression->Length + 1) * 2; BackTrackingBufferSize = Expression->Length * 2 + 1;
/* Allocate memory for both back-tracking buffers */ /* Allocate memory for both back-tracking buffers */
AllocatedBuffer = ExAllocatePoolWithTag(PagedPool | POOL_RAISE_IF_ALLOCATION_FAILURE, AllocatedBuffer = ExAllocatePoolWithTag(PagedPool | POOL_RAISE_IF_ALLOCATION_FAILURE,
@ -386,7 +386,7 @@ FsRtlIsDbcsInExpression(IN PANSI_STRING Expression,
continue; continue;
} }
/* Check DOS_DOT */ /* Check DOS_DOT */
else if (ExpressionChar == DOS_DOT) else if (ExpressionChar == ANSI_DOS_DOT)
{ {
if (EndOfName) continue; if (EndOfName) continue;

View file

@ -143,7 +143,7 @@ FsRtlIsNameInExpressionPrivate(IN PUNICODE_STRING Expression,
ASSERT((OldBackTracking == BackTrackingBuffer) || (OldBackTracking == OldBackTrackingBuffer)); ASSERT((OldBackTracking == BackTrackingBuffer) || (OldBackTracking == OldBackTrackingBuffer));
/* Calculate buffer size */ /* Calculate buffer size */
BackTrackingBufferSize = Expression->Length + 1; BackTrackingBufferSize = Expression->Length / sizeof(WCHAR) * 2 + 1;
/* Allocate memory for both back-tracking buffers */ /* Allocate memory for both back-tracking buffers */
AllocatedBuffer = ExAllocatePoolWithTag(PagedPool | POOL_RAISE_IF_ALLOCATION_FAILURE, AllocatedBuffer = ExAllocatePoolWithTag(PagedPool | POOL_RAISE_IF_ALLOCATION_FAILURE,