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

This commit is contained in:
Mikołaj Zalewski 2007-04-05 12:25:43 +02:00 committed by Alexandre Julliard
parent 10b1d00113
commit 3d7a65355e
2 changed files with 32 additions and 1 deletions

View File

@ -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);

View File

@ -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);