[INCLUDES] probe.h: use ExFreePoolWithTag for releasing unicode strings capture, and fully clear up said strings.

svn path=/trunk/; revision=71421
This commit is contained in:
Hermès Bélusca-Maïto 2016-05-26 23:17:59 +00:00
parent c9493245e5
commit 09084fe16a

View file

@ -144,7 +144,7 @@ ProbeAndCaptureUnicodeString(OUT PUNICODE_STRING Dest,
IN const UNICODE_STRING *UnsafeSrc) IN const UNICODE_STRING *UnsafeSrc)
{ {
NTSTATUS Status = STATUS_SUCCESS; NTSTATUS Status = STATUS_SUCCESS;
WCHAR *Buffer = NULL; PWCHAR Buffer = NULL;
ASSERT(Dest != NULL); ASSERT(Dest != NULL);
/* Probe the structure and buffer*/ /* Probe the structure and buffer*/
@ -162,9 +162,7 @@ ProbeAndCaptureUnicodeString(OUT PUNICODE_STRING Dest,
{ {
if (Dest->Length != 0) if (Dest->Length != 0)
{ {
ProbeForRead(Dest->Buffer, ProbeForRead(Dest->Buffer, Dest->Length, sizeof(WCHAR));
Dest->Length,
sizeof(WCHAR));
/* Allocate space for the buffer */ /* Allocate space for the buffer */
Buffer = (PWCHAR)ExAllocatePoolWithTag(PagedPool, Buffer = (PWCHAR)ExAllocatePoolWithTag(PagedPool,
@ -186,14 +184,14 @@ ProbeAndCaptureUnicodeString(OUT PUNICODE_STRING Dest,
} }
else else
{ {
/* sanitize structure */ /* Sanitize structure */
Dest->MaximumLength = 0; Dest->MaximumLength = 0;
Dest->Buffer = NULL; Dest->Buffer = NULL;
} }
} }
else else
{ {
/* sanitize structure */ /* Sanitize structure */
Dest->Length = 0; Dest->Length = 0;
Dest->MaximumLength = 0; Dest->MaximumLength = 0;
} }
@ -203,7 +201,7 @@ ProbeAndCaptureUnicodeString(OUT PUNICODE_STRING Dest,
/* Free allocated resources and zero the destination string */ /* Free allocated resources and zero the destination string */
if (Buffer != NULL) if (Buffer != NULL)
{ {
ExFreePool(Buffer); ExFreePoolWithTag(Buffer, 'RTSU');
} }
Dest->Length = 0; Dest->Length = 0;
Dest->MaximumLength = 0; Dest->MaximumLength = 0;
@ -232,8 +230,12 @@ ReleaseCapturedUnicodeString(IN PUNICODE_STRING CapturedString,
{ {
if(CurrentMode != KernelMode && CapturedString->Buffer != NULL) if(CurrentMode != KernelMode && CapturedString->Buffer != NULL)
{ {
ExFreePool(CapturedString->Buffer); ExFreePoolWithTag(CapturedString->Buffer, 'RTSU');
} }
CapturedString->Length = 0;
CapturedString->MaximumLength = 0;
CapturedString->Buffer = NULL;
} }
#endif /* INCLUDE_REACTOS_CAPTURE_H */ #endif /* INCLUDE_REACTOS_CAPTURE_H */