Module: wine Branch: master Commit: 33a6e66befaedfd93ee8e96d5a716e3fdd4d14a3 URL: http://source.winehq.org/git/wine.git/?a=commit;h=33a6e66befaedfd93ee8e96d5a...
Author: Ge van Geldorp ge@gse.nl Date: Tue Jan 20 15:07:15 2009 +0100
user32/tests: Prevent buffer overflow.
---
dlls/user32/tests/input.c | 26 +++++++++++++++++--------- 1 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c index 4a82200..cb03e6e 100644 --- a/dlls/user32/tests/input.c +++ b/dlls/user32/tests/input.c @@ -63,7 +63,7 @@ static long timetag = 0x10000000; static UINT (WINAPI *pSendInput) (UINT, INPUT*, size_t); static int (WINAPI *pGetMouseMovePointsEx) (UINT, LPMOUSEMOVEPOINT, LPMOUSEMOVEPOINT, int, DWORD);
-#define MAXKEYEVENTS 6 +#define MAXKEYEVENTS 10 #define MAXKEYMESSAGES MAXKEYEVENTS /* assuming a key event generates one and only one message */
@@ -799,10 +799,14 @@ static LRESULT CALLBACK WndProc2(HWND hWnd, UINT Msg, WPARAM wParam, Msg != WM_GETICON && Msg != WM_DEVICECHANGE) { - sent_messages[sent_messages_cnt].message = Msg; - sent_messages[sent_messages_cnt].flags = 0; - sent_messages[sent_messages_cnt].wParam = wParam; - sent_messages[sent_messages_cnt++].lParam = HIWORD(lParam) & (KF_UP|KF_EXTENDED); + 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].flags = 0; + sent_messages[sent_messages_cnt].wParam = wParam; + sent_messages[sent_messages_cnt++].lParam = HIWORD(lParam) & (KF_UP|KF_EXTENDED); + } } return DefWindowProc(hWnd, Msg, wParam, lParam); } @@ -813,10 +817,14 @@ static LRESULT CALLBACK hook_proc(int code, WPARAM wparam, LPARAM lparam)
if (code == HC_ACTION) { - sent_messages[sent_messages_cnt].message = wparam; - sent_messages[sent_messages_cnt].flags = hook; - sent_messages[sent_messages_cnt].wParam = hook_info->vkCode; - sent_messages[sent_messages_cnt++].lParam = hook_info->flags & (LLKHF_UP|LLKHF_EXTENDED); + 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].flags = hook; + sent_messages[sent_messages_cnt].wParam = hook_info->vkCode; + sent_messages[sent_messages_cnt++].lParam = hook_info->flags & (LLKHF_UP|LLKHF_EXTENDED); + }
if(0) /* For some reason not stable on Wine */ {