Author: hbelusca Date: Thu May 26 23:17:59 2016 New Revision: 71421
URL: http://svn.reactos.org/svn/reactos?rev=71421&view=rev Log: [INCLUDES] probe.h: use ExFreePoolWithTag for releasing unicode strings capture, and fully clear up said strings.
Modified: trunk/reactos/sdk/include/reactos/probe.h
Modified: trunk/reactos/sdk/include/reactos/probe.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/include/reactos/probe.h... ============================================================================== --- trunk/reactos/sdk/include/reactos/probe.h [iso-8859-1] (original) +++ trunk/reactos/sdk/include/reactos/probe.h [iso-8859-1] Thu May 26 23:17:59 2016 @@ -53,9 +53,9 @@
#define ProbeForReadGenericType(Ptr, Type, Default) \ (((ULONG_PTR)(Ptr) + sizeof(Type) - 1 < (ULONG_PTR)(Ptr) || \ - (ULONG_PTR)(Ptr) + sizeof(Type) - 1 >= (ULONG_PTR)MmUserProbeAddress) ? \ - ExRaiseAccessViolation(), Default : \ - *(const volatile Type *)(Ptr)) + (ULONG_PTR)(Ptr) + sizeof(Type) - 1 >= (ULONG_PTR)MmUserProbeAddress) ? \ + ExRaiseAccessViolation(), Default : \ + *(const volatile Type *)(Ptr))
#define ProbeForReadBoolean(Ptr) ProbeForReadGenericType(Ptr, BOOLEAN, FALSE) #define ProbeForReadUchar(Ptr) ProbeForReadGenericType(Ptr, UCHAR, 0) @@ -144,7 +144,7 @@ IN const UNICODE_STRING *UnsafeSrc) { NTSTATUS Status = STATUS_SUCCESS; - WCHAR *Buffer = NULL; + PWCHAR Buffer = NULL; ASSERT(Dest != NULL);
/* Probe the structure and buffer*/ @@ -162,9 +162,7 @@ { if (Dest->Length != 0) { - ProbeForRead(Dest->Buffer, - Dest->Length, - sizeof(WCHAR)); + ProbeForRead(Dest->Buffer, Dest->Length, sizeof(WCHAR));
/* Allocate space for the buffer */ Buffer = (PWCHAR)ExAllocatePoolWithTag(PagedPool, @@ -186,14 +184,14 @@ } else { - /* sanitize structure */ + /* Sanitize structure */ Dest->MaximumLength = 0; Dest->Buffer = NULL; } } else { - /* sanitize structure */ + /* Sanitize structure */ Dest->Length = 0; Dest->MaximumLength = 0; } @@ -203,7 +201,7 @@ /* Free allocated resources and zero the destination string */ if (Buffer != NULL) { - ExFreePool(Buffer); + ExFreePoolWithTag(Buffer, 'RTSU'); } Dest->Length = 0; Dest->MaximumLength = 0; @@ -232,8 +230,12 @@ { 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 */