mirror of
https://github.com/reactos/reactos.git
synced 2025-07-27 07:41:51 +00:00
[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:
parent
c9493245e5
commit
09084fe16a
1 changed files with 13 additions and 11 deletions
|
@ -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 */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue