mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 10:56:05 +00:00
- GetConsoleAliasA: Check for invalid target buffer, failed memory allocations (3x)
- Found by Amine Khaldi svn path=/trunk/; revision=42764
This commit is contained in:
parent
8739063551
commit
9f218a3f22
1 changed files with 25 additions and 1 deletions
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/kernel32/misc/console.c
|
||||
* FILE: dll/win32/kernel32/misc/console.c
|
||||
* PURPOSE: Win32 server console functions
|
||||
* PROGRAMMER: James Tabor
|
||||
* <jimtabor@adsl-64-217-116-74.dsl.hstntx.swbell.net>
|
||||
|
@ -426,15 +426,39 @@ GetConsoleAliasA(LPSTR lpSource,
|
|||
|
||||
DPRINT("GetConsoleAliasA entered\n");
|
||||
|
||||
if (lpTargetBuffer == NULL)
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return 0;
|
||||
}
|
||||
|
||||
dwSourceSize = (strlen(lpSource)+1) * sizeof(WCHAR);
|
||||
lpwSource = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwSourceSize);
|
||||
if (lpwSource == NULL)
|
||||
{
|
||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return 0;
|
||||
}
|
||||
MultiByteToWideChar(CP_ACP, 0, lpSource, -1, lpwSource, dwSourceSize);
|
||||
|
||||
dwExeNameSize = (strlen(lpExeName)+1) * sizeof(WCHAR);
|
||||
lpwExeName = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwExeNameSize);
|
||||
if (lpwExeName == NULL)
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, lpwSource);
|
||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return 0;
|
||||
}
|
||||
MultiByteToWideChar(CP_ACP, 0, lpExeName, -1, lpwExeName, dwExeNameSize);
|
||||
|
||||
lpwTargetBuffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, TargetBufferLength * sizeof(WCHAR));
|
||||
if (lpwTargetBuffer == NULL)
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, lpwSource);
|
||||
HeapFree(GetProcessHeap(), 0, lpwExeName);
|
||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return 0;
|
||||
}
|
||||
|
||||
dwResult = GetConsoleAliasW(lpwSource, lpwTargetBuffer, TargetBufferLength * sizeof(WCHAR), lpwExeName);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue