mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 17:34:57 +00:00
fixed converting the unicode string back to ansi in GetNamedPipeHandleStateA, also check if memory allocation failed (reported by M Bealby in bug #1110)
svn path=/trunk/; revision=20077
This commit is contained in:
parent
d33dc74f17
commit
f4d98daa91
1 changed files with 12 additions and 5 deletions
|
@ -905,15 +905,19 @@ GetNamedPipeHandleStateA(HANDLE hNamedPipe,
|
||||||
LPSTR lpUserName,
|
LPSTR lpUserName,
|
||||||
DWORD nMaxUserNameSize)
|
DWORD nMaxUserNameSize)
|
||||||
{
|
{
|
||||||
UNICODE_STRING UserNameW;
|
UNICODE_STRING UserNameW = {0};
|
||||||
ANSI_STRING UserNameA;
|
ANSI_STRING UserNameA;
|
||||||
BOOL Ret;
|
BOOL Ret;
|
||||||
|
|
||||||
if(lpUserName != NULL)
|
if(lpUserName != NULL)
|
||||||
{
|
{
|
||||||
UserNameW.Length = 0;
|
|
||||||
UserNameW.MaximumLength = nMaxUserNameSize * sizeof(WCHAR);
|
UserNameW.MaximumLength = nMaxUserNameSize * sizeof(WCHAR);
|
||||||
UserNameW.Buffer = HeapAlloc(GetCurrentProcess(), 0, UserNameW.MaximumLength);
|
UserNameW.Buffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, UserNameW.MaximumLength);
|
||||||
|
if (UserNameW.Buffer == NULL)
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
UserNameA.Buffer = lpUserName;
|
UserNameA.Buffer = lpUserName;
|
||||||
UserNameA.Length = 0;
|
UserNameA.Length = 0;
|
||||||
|
@ -930,7 +934,10 @@ GetNamedPipeHandleStateA(HANDLE hNamedPipe,
|
||||||
|
|
||||||
if(Ret && lpUserName != NULL)
|
if(Ret && lpUserName != NULL)
|
||||||
{
|
{
|
||||||
NTSTATUS Status = RtlUnicodeStringToAnsiString(&UserNameA, &UserNameW, FALSE);
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
RtlInitUnicodeString(&UserNameW, UserNameW.Buffer);
|
||||||
|
Status = RtlUnicodeStringToAnsiString(&UserNameA, &UserNameW, FALSE);
|
||||||
if(!NT_SUCCESS(Status))
|
if(!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
SetLastErrorByStatus(Status);
|
SetLastErrorByStatus(Status);
|
||||||
|
@ -940,7 +947,7 @@ GetNamedPipeHandleStateA(HANDLE hNamedPipe,
|
||||||
|
|
||||||
if(UserNameW.Buffer != NULL)
|
if(UserNameW.Buffer != NULL)
|
||||||
{
|
{
|
||||||
HeapFree(GetCurrentProcess(), 0, UserNameW.Buffer);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, UserNameW.Buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ret;
|
return Ret;
|
||||||
|
|
Loading…
Reference in a new issue