https://git.reactos.org/?p=reactos.git;a=commitdiff;h=695e00fbbd17f4a30201d…
commit 695e00fbbd17f4a30201d262381a553da0d0805a
Author: Bartosz Brachaczek <b.brachaczek(a)gmail.com>
AuthorDate: Mon Apr 1 01:58:21 2019 +0200
Commit: Pierre Schweitzer <pierre(a)reactos.org>
CommitDate: Mon Apr 1 08:27:59 2019 +0200
[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
---
ntoskrnl/fsrtl/dbcsname.c | 4 ++--
ntoskrnl/fsrtl/name.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/ntoskrnl/fsrtl/dbcsname.c b/ntoskrnl/fsrtl/dbcsname.c
index 2c7300f388..3b1afd801e 100644
--- a/ntoskrnl/fsrtl/dbcsname.c
+++ b/ntoskrnl/fsrtl/dbcsname.c
@@ -291,7 +291,7 @@ FsRtlIsDbcsInExpression(IN PANSI_STRING Expression,
ASSERT((OldBackTracking == BackTrackingBuffer) || (OldBackTracking ==
OldBackTrackingBuffer));
/* Calculate buffer size */
- BackTrackingBufferSize = (Expression->Length + 1) * 2;
+ BackTrackingBufferSize = Expression->Length * 2 + 1;
/* Allocate memory for both back-tracking buffers */
AllocatedBuffer = ExAllocatePoolWithTag(PagedPool |
POOL_RAISE_IF_ALLOCATION_FAILURE,
@@ -386,7 +386,7 @@ FsRtlIsDbcsInExpression(IN PANSI_STRING Expression,
continue;
}
/* Check DOS_DOT */
- else if (ExpressionChar == DOS_DOT)
+ else if (ExpressionChar == ANSI_DOS_DOT)
{
if (EndOfName) continue;
diff --git a/ntoskrnl/fsrtl/name.c b/ntoskrnl/fsrtl/name.c
index ef760c3bf5..3d2b33ea83 100644
--- a/ntoskrnl/fsrtl/name.c
+++ b/ntoskrnl/fsrtl/name.c
@@ -143,7 +143,7 @@ FsRtlIsNameInExpressionPrivate(IN PUNICODE_STRING Expression,
ASSERT((OldBackTracking == BackTrackingBuffer) || (OldBackTracking ==
OldBackTrackingBuffer));
/* Calculate buffer size */
- BackTrackingBufferSize = Expression->Length + 1;
+ BackTrackingBufferSize = Expression->Length / sizeof(WCHAR) * 2 +
1;
/* Allocate memory for both back-tracking buffers */
AllocatedBuffer = ExAllocatePoolWithTag(PagedPool |
POOL_RAISE_IF_ALLOCATION_FAILURE,