From: Nikolay Sivov Date: Thu, 15 Oct 2009 10:49:30 +0000 (+0400) Subject: comctl32/tooltips: Fix an obviously wrong structure size check. X-Git-Tag: wine-1.1.32~311 X-Git-Url: http://git.etersoft.ru/projects/?a=commitdiff_plain;h=98a7d8cf9d3c9984af7fec043a07ec73e1383ee3;p=wine%2Feterwine.git comctl32/tooltips: Fix an obviously wrong structure size check. --- diff --git a/dlls/comctl32/tests/tooltips.c b/dlls/comctl32/tests/tooltips.c index b8c46cb52c..ddc162ac58 100644 --- a/dlls/comctl32/tests/tooltips.c +++ b/dlls/comctl32/tests/tooltips.c @@ -416,6 +416,56 @@ static void test_gettext(void) DestroyWindow(hwnd); } +static void test_ttm_gettoolinfo(void) +{ + TTTOOLINFOA ti; + TTTOOLINFOW tiW; + HWND hwnd; + DWORD r; + + hwnd = CreateWindowExA(0, TOOLTIPS_CLASSA, NULL, 0, + 10, 10, 300, 100, + NULL, NULL, NULL, 0); + + ti.cbSize = TTTOOLINFOA_V2_SIZE; + ti.hwnd = NULL; + ti.hinst = GetModuleHandleA(NULL); + ti.uFlags = 0; + ti.uId = 0x1234ABCD; + ti.lpszText = NULL; + ti.lParam = 0xdeadbeef; + GetClientRect(hwnd, &ti.rect); + r = SendMessageA(hwnd, TTM_ADDTOOLA, 0, (LPARAM)&ti); + ok(r, "Adding the tool to the tooltip failed\n"); + + ti.cbSize = TTTOOLINFOA_V2_SIZE; + ti.lParam = 0xaaaaaaaa; + r = SendMessageA(hwnd, TTM_GETTOOLINFOA, 0, (LPARAM)&ti); + ok(r, "Getting tooltip info failed\n"); + ok(0xdeadbeef == ti.lParam, "Expected 0xdeadbeef, got %lx\n", ti.lParam); + + tiW.cbSize = TTTOOLINFOW_V2_SIZE; + tiW.hwnd = NULL; + tiW.uId = 0x1234ABCD; + tiW.lParam = 0xaaaaaaaa; + r = SendMessageA(hwnd, TTM_GETTOOLINFOW, 0, (LPARAM)&tiW); + ok(r, "Getting tooltip info failed\n"); + ok(0xdeadbeef == tiW.lParam, "Expected 0xdeadbeef, got %lx\n", tiW.lParam); + + ti.cbSize = TTTOOLINFOA_V2_SIZE; + ti.uId = 0x1234ABCD; + ti.lParam = 0xaaaaaaaa; + r = SendMessageA(hwnd, TTM_SETTOOLINFOA, 0, (LPARAM)&ti); + + ti.cbSize = TTTOOLINFOA_V2_SIZE; + ti.lParam = 0xdeadbeef; + r = SendMessageA(hwnd, TTM_GETTOOLINFOA, 0, (LPARAM)&ti); + ok(r, "Getting tooltip info failed\n"); + ok(0xaaaaaaaa == ti.lParam, "Expected 0xaaaaaaaa, got %lx\n", ti.lParam); + + DestroyWindow(hwnd); +} + START_TEST(tooltips) { InitCommonControls(); @@ -423,4 +473,5 @@ START_TEST(tooltips) test_create_tooltip(); test_customdraw(); test_gettext(); + test_ttm_gettoolinfo(); } diff --git a/dlls/comctl32/tooltips.c b/dlls/comctl32/tooltips.c index 54600e81c8..05cd0dc3c2 100644 --- a/dlls/comctl32/tooltips.c +++ b/dlls/comctl32/tooltips.c @@ -1076,7 +1076,7 @@ TOOLTIPS_AddToolA (TOOLTIPS_INFO *infoPtr, const TTTOOLINFOA *lpToolInfo) } } - if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOA)) + if (lpToolInfo->cbSize >= TTTOOLINFOA_V2_SIZE) toolPtr->lParam = lpToolInfo->lParam; /* install subclassing hook */ @@ -1164,7 +1164,7 @@ TOOLTIPS_AddToolW (TOOLTIPS_INFO *infoPtr, const TTTOOLINFOW *lpToolInfo) } } - if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOW)) + if (lpToolInfo->cbSize >= TTTOOLINFOW_V2_SIZE) toolPtr->lParam = lpToolInfo->lParam; /* install subclassing hook */ @@ -1337,7 +1337,7 @@ TOOLTIPS_EnumToolsA (const TOOLTIPS_INFO *infoPtr, UINT uIndex, LPTTTOOLINFOA lp /* lpToolInfo->lpszText = toolPtr->lpszText; */ lpToolInfo->lpszText = NULL; /* FIXME */ - if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOA)) + if (lpToolInfo->cbSize >= TTTOOLINFOA_V2_SIZE) lpToolInfo->lParam = toolPtr->lParam; return TRUE; @@ -1369,7 +1369,7 @@ TOOLTIPS_EnumToolsW (const TOOLTIPS_INFO *infoPtr, UINT uIndex, LPTTTOOLINFOW lp /* lpToolInfo->lpszText = toolPtr->lpszText; */ lpToolInfo->lpszText = NULL; /* FIXME */ - if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOW)) + if (lpToolInfo->cbSize >= TTTOOLINFOW_V2_SIZE) lpToolInfo->lParam = toolPtr->lParam; return TRUE; @@ -1416,7 +1416,7 @@ TOOLTIPS_GetCurrentToolA (const TOOLTIPS_INFO *infoPtr, LPTTTOOLINFOA lpToolInfo /* lpToolInfo->lpszText = toolPtr->lpszText; */ lpToolInfo->lpszText = NULL; /* FIXME */ - if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOA)) + if (lpToolInfo->cbSize >= TTTOOLINFOA_V2_SIZE) lpToolInfo->lParam = toolPtr->lParam; return TRUE; @@ -1448,7 +1448,7 @@ TOOLTIPS_GetCurrentToolW (const TOOLTIPS_INFO *infoPtr, LPTTTOOLINFOW lpToolInfo /* lpToolInfo->lpszText = toolPtr->lpszText; */ lpToolInfo->lpszText = NULL; /* FIXME */ - if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOW)) + if (lpToolInfo->cbSize >= TTTOOLINFOW_V2_SIZE) lpToolInfo->lParam = toolPtr->lParam; return TRUE; @@ -1602,7 +1602,7 @@ TOOLTIPS_GetToolInfoA (const TOOLTIPS_INFO *infoPtr, LPTTTOOLINFOA lpToolInfo) /* lpToolInfo->lpszText = toolPtr->lpszText; */ lpToolInfo->lpszText = NULL; /* FIXME */ - if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOA)) + if (lpToolInfo->cbSize >= TTTOOLINFOA_V2_SIZE) lpToolInfo->lParam = toolPtr->lParam; return TRUE; @@ -1637,7 +1637,7 @@ TOOLTIPS_GetToolInfoW (const TOOLTIPS_INFO *infoPtr, LPTTTOOLINFOW lpToolInfo) /* lpToolInfo->lpszText = toolPtr->lpszText; */ lpToolInfo->lpszText = NULL; /* FIXME */ - if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOW)) + if (lpToolInfo->cbSize >= TTTOOLINFOW_V2_SIZE) lpToolInfo->lParam = toolPtr->lParam; return TRUE; @@ -1660,7 +1660,7 @@ TOOLTIPS_HitTestA (const TOOLTIPS_INFO *infoPtr, LPTTHITTESTINFOA lptthit) TRACE("tool %d!\n", nTool); /* copy tool data */ - if (lptthit->ti.cbSize >= sizeof(TTTOOLINFOA)) { + if (lptthit->ti.cbSize >= TTTOOLINFOA_V1_SIZE) { toolPtr = &infoPtr->tools[nTool]; lptthit->ti.uFlags = toolPtr->uFlags; @@ -1670,7 +1670,8 @@ TOOLTIPS_HitTestA (const TOOLTIPS_INFO *infoPtr, LPTTHITTESTINFOA lptthit) lptthit->ti.hinst = toolPtr->hinst; /* lptthit->ti.lpszText = toolPtr->lpszText; */ lptthit->ti.lpszText = NULL; /* FIXME */ - lptthit->ti.lParam = toolPtr->lParam; + if (lptthit->ti.cbSize >= TTTOOLINFOA_V2_SIZE) + lptthit->ti.lParam = toolPtr->lParam; } return TRUE; @@ -1693,7 +1694,7 @@ TOOLTIPS_HitTestW (const TOOLTIPS_INFO *infoPtr, LPTTHITTESTINFOW lptthit) TRACE("tool %d!\n", nTool); /* copy tool data */ - if (lptthit->ti.cbSize >= sizeof(TTTOOLINFOW)) { + if (lptthit->ti.cbSize >= TTTOOLINFOW_V1_SIZE) { toolPtr = &infoPtr->tools[nTool]; lptthit->ti.uFlags = toolPtr->uFlags; @@ -1703,7 +1704,8 @@ TOOLTIPS_HitTestW (const TOOLTIPS_INFO *infoPtr, LPTTHITTESTINFOW lptthit) lptthit->ti.hinst = toolPtr->hinst; /* lptthit->ti.lpszText = toolPtr->lpszText; */ lptthit->ti.lpszText = NULL; /* FIXME */ - lptthit->ti.lParam = toolPtr->lParam; + if (lptthit->ti.cbSize >= TTTOOLINFOW_V2_SIZE) + lptthit->ti.lParam = toolPtr->lParam; } return TRUE; @@ -2018,7 +2020,7 @@ TOOLTIPS_SetToolInfoA (TOOLTIPS_INFO *infoPtr, const TTTOOLINFOA *lpToolInfo) } } - if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOA)) + if (lpToolInfo->cbSize >= TTTOOLINFOA_V2_SIZE) toolPtr->lParam = lpToolInfo->lParam; return 0; @@ -2072,7 +2074,7 @@ TOOLTIPS_SetToolInfoW (TOOLTIPS_INFO *infoPtr, const TTTOOLINFOW *lpToolInfo) } } - if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOW)) + if (lpToolInfo->cbSize >= TTTOOLINFOW_V2_SIZE) toolPtr->lParam = lpToolInfo->lParam; if (infoPtr->nCurrentTool == nTool) diff --git a/include/commctrl.h b/include/commctrl.h index 2add8b8c14..f2ea3aeefd 100644 --- a/include/commctrl.h +++ b/include/commctrl.h @@ -1774,6 +1774,10 @@ typedef struct tagTOOLINFOW { #define TTTOOLINFOA_V1_SIZE CCSIZEOF_STRUCT(TTTOOLINFOA, lpszText) #define TTTOOLINFOW_V1_SIZE CCSIZEOF_STRUCT(TTTOOLINFOW, lpszText) #define TTTOOLINFO_V1_SIZE CCSIZEOF_STRUCT(WINELIB_NAME_AW(TTTOOLINFO), lpszText) +#define TTTOOLINFOA_V2_SIZE CCSIZEOF_STRUCT(TTTOOLINFOA, lParam) +#define TTTOOLINFOW_V2_SIZE CCSIZEOF_STRUCT(TTTOOLINFOW, lParam) +#define TTTOOLINFOA_V3_SIZE CCSIZEOF_STRUCT(TTTOOLINFOA, lpReserved) +#define TTTOOLINFOW_V3_SIZE CCSIZEOF_STRUCT(TTTOOLINFOW, lpReserved) typedef struct _TT_HITTESTINFOA {