Commit 3d7a6535 authored by Mikołaj Zalewski's avatar Mikołaj Zalewski Committed by Alexandre Julliard

comctl32: toolbar: Don't execute TB_GETBUTTONINFO if cbSize is invalid.

parent 10b1d001
......@@ -864,6 +864,28 @@ static void test_sizes(void)
DestroyWindow(hToolbar);
}
static void test_getbuttoninfo(void)
{
HWND hToolbar = NULL;
int i;
rebuild_toolbar_with_buttons(&hToolbar);
for (i = 0; i < 128; i++)
{
TBBUTTONINFO tbi;
int ret;
tbi.cbSize = i;
tbi.dwMask = TBIF_BYINDEX | TBIF_COMMAND;
ret = (int)SendMessage(hToolbar, TB_GETBUTTONINFO, 0, (LPARAM)&tbi);
if (i == sizeof(TBBUTTONINFO)) {
compare(ret, 0, "%d");
} else {
compare(ret, -1, "%d");
}
}
DestroyWindow(hToolbar);
}
static void test_createtoolbarex()
{
......@@ -933,6 +955,7 @@ START_TEST(toolbar)
test_add_string();
test_hotitem();
test_sizes();
test_getbuttoninfo();
test_createtoolbarex();
PostQuitMessage(0);
......
......@@ -3364,8 +3364,16 @@ TOOLBAR_GetButtonInfoT(HWND hwnd, WPARAM wParam, LPARAM lParam, BOOL bUnicode)
if (lpTbInfo == NULL)
return -1;
if (lpTbInfo->cbSize < sizeof(TBBUTTONINFOA))
/* MSDN documents a iImageLabel field added in Vista but it is not present in
* the headers and tests shows that even with comctl 6 Vista accepts only the
* original TBBUTTONINFO size
*/
if (lpTbInfo->cbSize != sizeof(TBBUTTONINFOW))
{
WARN("Invalid button size\n");
return -1;
}
nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam,
lpTbInfo->dwMask & 0x80000000);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment