mirror of
https://github.com/reactos/reactos.git
synced 2024-10-04 08:25:53 +00:00
Fix parameter validation in WM_GETTEXT and GetWindowText.
svn path=/trunk/; revision=17944
This commit is contained in:
parent
7936d2bbcf
commit
1dc1b56c2f
|
@ -1426,10 +1426,6 @@ DefWindowProcA(HWND hWnd,
|
||||||
LPSTR AnsiBuffer = (LPSTR)lParam;
|
LPSTR AnsiBuffer = (LPSTR)lParam;
|
||||||
INT Length;
|
INT Length;
|
||||||
|
|
||||||
if (wParam > 1)
|
|
||||||
{
|
|
||||||
*((PWSTR)lParam) = '\0';
|
|
||||||
}
|
|
||||||
Buffer = HeapAlloc(GetProcessHeap(), 0, wParam * sizeof(WCHAR));
|
Buffer = HeapAlloc(GetProcessHeap(), 0, wParam * sizeof(WCHAR));
|
||||||
if (!Buffer)
|
if (!Buffer)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -1505,10 +1501,6 @@ DefWindowProcW(HWND hWnd,
|
||||||
|
|
||||||
case WM_GETTEXT:
|
case WM_GETTEXT:
|
||||||
{
|
{
|
||||||
if (wParam > 1)
|
|
||||||
{
|
|
||||||
*((PWSTR)lParam) = L'\0';
|
|
||||||
}
|
|
||||||
return (LRESULT)NtUserInternalGetWindowText(hWnd, (PWSTR)lParam, wParam);
|
return (LRESULT)NtUserInternalGetWindowText(hWnd, (PWSTR)lParam, wParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -820,21 +820,19 @@ int STDCALL
|
||||||
GetWindowTextA(HWND hWnd, LPSTR lpString, int nMaxCount)
|
GetWindowTextA(HWND hWnd, LPSTR lpString, int nMaxCount)
|
||||||
{
|
{
|
||||||
DWORD ProcessId;
|
DWORD ProcessId;
|
||||||
if(!NtUserGetWindowThreadProcessId(hWnd, &ProcessId))
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(ProcessId != GetCurrentProcessId())
|
if (lpString == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (!NtUserGetWindowThreadProcessId(hWnd, &ProcessId))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (ProcessId != GetCurrentProcessId())
|
||||||
{
|
{
|
||||||
/* do not send WM_GETTEXT messages to other processes */
|
/* do not send WM_GETTEXT messages to other processes */
|
||||||
LPWSTR Buffer;
|
LPWSTR Buffer;
|
||||||
INT Length;
|
INT Length;
|
||||||
|
|
||||||
if (nMaxCount > 1)
|
|
||||||
{
|
|
||||||
*((PWSTR)lpString) = '\0';
|
|
||||||
}
|
|
||||||
Buffer = HeapAlloc(GetProcessHeap(), 0, nMaxCount * sizeof(WCHAR));
|
Buffer = HeapAlloc(GetProcessHeap(), 0, nMaxCount * sizeof(WCHAR));
|
||||||
if (!Buffer)
|
if (!Buffer)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -845,13 +843,12 @@ GetWindowTextA(HWND hWnd, LPSTR lpString, int nMaxCount)
|
||||||
{
|
{
|
||||||
lpString[0] = '\0';
|
lpString[0] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
HeapFree(GetProcessHeap(), 0, Buffer);
|
HeapFree(GetProcessHeap(), 0, Buffer);
|
||||||
|
|
||||||
return (LRESULT)Length;
|
return (LRESULT)Length;
|
||||||
}
|
}
|
||||||
|
|
||||||
return(SendMessageA(hWnd, WM_GETTEXT, nMaxCount, (LPARAM)lpString));
|
return SendMessageA(hWnd, WM_GETTEXT, nMaxCount, (LPARAM)lpString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -903,29 +900,20 @@ GetWindowTextLengthW(HWND hWnd)
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
int STDCALL
|
int STDCALL
|
||||||
GetWindowTextW(
|
GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
|
||||||
HWND hWnd,
|
|
||||||
LPWSTR lpString,
|
|
||||||
int nMaxCount)
|
|
||||||
{
|
{
|
||||||
DWORD ProcessId;
|
DWORD ProcessId;
|
||||||
if(!NtUserGetWindowThreadProcessId(hWnd, &ProcessId))
|
|
||||||
{
|
if (lpString == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
|
|
||||||
if(ProcessId == GetCurrentProcessId())
|
if (!NtUserGetWindowThreadProcessId(hWnd, &ProcessId))
|
||||||
{
|
return 0;
|
||||||
return(SendMessageW(hWnd, WM_GETTEXT, nMaxCount, (LPARAM)lpString));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* do not send WM_GETTEXT messages to other processes */
|
if (ProcessId == GetCurrentProcessId())
|
||||||
if (nMaxCount > 1)
|
return SendMessageW(hWnd, WM_GETTEXT, nMaxCount, (LPARAM)lpString);
|
||||||
{
|
|
||||||
*((PWSTR)lpString) = L'\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
return (LRESULT)NtUserInternalGetWindowText(hWnd, (PWSTR)lpString, nMaxCount);
|
return NtUserInternalGetWindowText(hWnd, lpString, nMaxCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD STDCALL
|
DWORD STDCALL
|
||||||
|
|
Loading…
Reference in a new issue