user32/tests: Prevent buffer overflow.
This commit is contained in:
parent
efe334b5b1
commit
33a6e66bef
|
@ -63,7 +63,7 @@ static long timetag = 0x10000000;
|
||||||
static UINT (WINAPI *pSendInput) (UINT, INPUT*, size_t);
|
static UINT (WINAPI *pSendInput) (UINT, INPUT*, size_t);
|
||||||
static int (WINAPI *pGetMouseMovePointsEx) (UINT, LPMOUSEMOVEPOINT, LPMOUSEMOVEPOINT, int, DWORD);
|
static int (WINAPI *pGetMouseMovePointsEx) (UINT, LPMOUSEMOVEPOINT, LPMOUSEMOVEPOINT, int, DWORD);
|
||||||
|
|
||||||
#define MAXKEYEVENTS 6
|
#define MAXKEYEVENTS 10
|
||||||
#define MAXKEYMESSAGES MAXKEYEVENTS /* assuming a key event generates one
|
#define MAXKEYMESSAGES MAXKEYEVENTS /* assuming a key event generates one
|
||||||
and only one message */
|
and only one message */
|
||||||
|
|
||||||
|
@ -798,12 +798,16 @@ static LRESULT CALLBACK WndProc2(HWND hWnd, UINT Msg, WPARAM wParam,
|
||||||
Msg != WM_GETTEXT &&
|
Msg != WM_GETTEXT &&
|
||||||
Msg != WM_GETICON &&
|
Msg != WM_GETICON &&
|
||||||
Msg != WM_DEVICECHANGE)
|
Msg != WM_DEVICECHANGE)
|
||||||
|
{
|
||||||
|
ok(sent_messages_cnt < MAXKEYMESSAGES, "Too many messages\n");
|
||||||
|
if (sent_messages_cnt < MAXKEYMESSAGES)
|
||||||
{
|
{
|
||||||
sent_messages[sent_messages_cnt].message = Msg;
|
sent_messages[sent_messages_cnt].message = Msg;
|
||||||
sent_messages[sent_messages_cnt].flags = 0;
|
sent_messages[sent_messages_cnt].flags = 0;
|
||||||
sent_messages[sent_messages_cnt].wParam = wParam;
|
sent_messages[sent_messages_cnt].wParam = wParam;
|
||||||
sent_messages[sent_messages_cnt++].lParam = HIWORD(lParam) & (KF_UP|KF_EXTENDED);
|
sent_messages[sent_messages_cnt++].lParam = HIWORD(lParam) & (KF_UP|KF_EXTENDED);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return DefWindowProc(hWnd, Msg, wParam, lParam);
|
return DefWindowProc(hWnd, Msg, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -812,11 +816,15 @@ static LRESULT CALLBACK hook_proc(int code, WPARAM wparam, LPARAM lparam)
|
||||||
KBDLLHOOKSTRUCT *hook_info = (KBDLLHOOKSTRUCT *)lparam;
|
KBDLLHOOKSTRUCT *hook_info = (KBDLLHOOKSTRUCT *)lparam;
|
||||||
|
|
||||||
if (code == HC_ACTION)
|
if (code == HC_ACTION)
|
||||||
|
{
|
||||||
|
ok(sent_messages_cnt < MAXKEYMESSAGES, "Too many messages\n");
|
||||||
|
if (sent_messages_cnt < MAXKEYMESSAGES)
|
||||||
{
|
{
|
||||||
sent_messages[sent_messages_cnt].message = wparam;
|
sent_messages[sent_messages_cnt].message = wparam;
|
||||||
sent_messages[sent_messages_cnt].flags = hook;
|
sent_messages[sent_messages_cnt].flags = hook;
|
||||||
sent_messages[sent_messages_cnt].wParam = hook_info->vkCode;
|
sent_messages[sent_messages_cnt].wParam = hook_info->vkCode;
|
||||||
sent_messages[sent_messages_cnt++].lParam = hook_info->flags & (LLKHF_UP|LLKHF_EXTENDED);
|
sent_messages[sent_messages_cnt++].lParam = hook_info->flags & (LLKHF_UP|LLKHF_EXTENDED);
|
||||||
|
}
|
||||||
|
|
||||||
if(0) /* For some reason not stable on Wine */
|
if(0) /* For some reason not stable on Wine */
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue