From 9ee5f26570ebd25aa1b5d6a27a043fef3334e2b5 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Mon, 29 Jun 2009 20:00:16 +0400 Subject: [PATCH] comctl32/rebar: Use proper structure size in tests and parameter checks. --- dlls/comctl32/rebar.c | 14 +++++++------- dlls/comctl32/tests/rebar.c | 18 +++++++++--------- include/commctrl.h | 3 +++ 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/dlls/comctl32/rebar.c b/dlls/comctl32/rebar.c index 8e18e228192..e11d974e208 100644 --- a/dlls/comctl32/rebar.c +++ b/dlls/comctl32/rebar.c @@ -1699,11 +1699,11 @@ REBAR_CommonSetupBand(HWND hwnd, const REBARBANDINFOW *lprbbi, REBAR_BAND *lpBan if( (lprbbi->fMask & RBBIM_CHILDSIZE) && ( (lpBand->cxMinChild != lprbbi->cxMinChild) || (lpBand->cyMinChild != lprbbi->cyMinChild ) || - ( (lprbbi->cbSize >= sizeof (REBARBANDINFOA) && (lpBand->fStyle & RBBS_VARIABLEHEIGHT)) && + ( (lprbbi->cbSize >= REBARBANDINFOA_V6_SIZE && (lpBand->fStyle & RBBS_VARIABLEHEIGHT)) && ( (lpBand->cyChild != lprbbi->cyChild ) || (lpBand->cyMaxChild != lprbbi->cyMaxChild ) || (lpBand->cyIntegral != lprbbi->cyIntegral ) ) ) || - ( (lprbbi->cbSize < sizeof (REBARBANDINFOA)) && + ( (lprbbi->cbSize < REBARBANDINFOA_V6_SIZE) && ( (lpBand->cyChild || lpBand->cyMaxChild || lpBand->cyIntegral ) ) ) ) ) @@ -1711,7 +1711,7 @@ REBAR_CommonSetupBand(HWND hwnd, const REBARBANDINFOW *lprbbi, REBAR_BAND *lpBan lpBand->cxMinChild = lprbbi->cxMinChild; lpBand->cyMinChild = lprbbi->cyMinChild; /* These fields where added in WIN32_IE == 0x400 and are set only for RBBS_VARIABLEHEIGHT bands */ - if (lprbbi->cbSize >= sizeof (REBARBANDINFOA) && (lpBand->fStyle & RBBS_VARIABLEHEIGHT)) { + if (lprbbi->cbSize >= REBARBANDINFOA_V6_SIZE && (lpBand->fStyle & RBBS_VARIABLEHEIGHT)) { lpBand->cyMaxChild = lprbbi->cyMaxChild; lpBand->cyIntegral = lprbbi->cyIntegral; @@ -1747,7 +1747,7 @@ REBAR_CommonSetupBand(HWND hwnd, const REBARBANDINFOW *lprbbi, REBAR_BAND *lpBan } /* check for additional data */ - if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) { + if (lprbbi->cbSize >= REBARBANDINFOA_V6_SIZE) { if( (lprbbi->fMask & RBBIM_IDEALSIZE) && ( lpBand->cxIdeal != lprbbi->cxIdeal ) ) { @@ -2167,7 +2167,7 @@ REBAR_GetBandInfoT(const REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam, BOOL lprbbi->cyMinChild = lpBand->cyMinChild; /* to make tests pass we follow Windows behaviour and allow to read these fields only * for RBBS_VARIABLEHEIGHTS bands */ - if (lprbbi->cbSize >= sizeof (REBARBANDINFOA) && (lpBand->fStyle & RBBS_VARIABLEHEIGHT)) { + if (lprbbi->cbSize >= REBARBANDINFOW_V6_SIZE && (lpBand->fStyle & RBBS_VARIABLEHEIGHT)) { lprbbi->cyChild = lpBand->cyChild; lprbbi->cyMaxChild = lpBand->cyMaxChild; lprbbi->cyIntegral = lpBand->cyIntegral; @@ -2184,7 +2184,7 @@ REBAR_GetBandInfoT(const REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam, BOOL lprbbi->wID = lpBand->wID; /* check for additional data */ - if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) { + if (lprbbi->cbSize >= REBARBANDINFOW_V6_SIZE) { if (lprbbi->fMask & RBBIM_IDEALSIZE) lprbbi->cxIdeal = lpBand->cxIdeal; @@ -2424,7 +2424,7 @@ REBAR_InsertBandT(REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam, BOOL bUnico REBAR_CommonSetupBand(infoPtr->hwndSelf, lprbbi, lpBand); /* Make sure the defaults for these are correct */ - if (lprbbi->cbSize < sizeof (REBARBANDINFOA) || !(lpBand->fStyle & RBBS_VARIABLEHEIGHT)) { + if (lprbbi->cbSize < REBARBANDINFOA_V6_SIZE || !(lpBand->fStyle & RBBS_VARIABLEHEIGHT)) { lpBand->cyChild = lpBand->cyMinChild; lpBand->cyMaxChild = 0x7fffffff; lpBand->cyIntegral = 0; diff --git a/dlls/comctl32/tests/rebar.c b/dlls/comctl32/tests/rebar.c index c819bc78f9b..2af9ab13a5f 100644 --- a/dlls/comctl32/tests/rebar.c +++ b/dlls/comctl32/tests/rebar.c @@ -150,7 +150,7 @@ static void dump_sizes(HWND hRebar) for (i=0; ibands[i].fStyle & RBBS_HIDDEN)) \ check_rect("band", rc, res->bands[i].rc); \ - rbi.cbSize = sizeof(REBARBANDINFO); \ + rbi.cbSize = REBARBANDINFOA_V6_SIZE; \ rbi.fMask = RBBIM_STYLE | RBBIM_SIZE; \ ok(SendMessageA(hRebar, RB_GETBANDINFO, i, (LPARAM)&rbi) == 1, "RB_GETBANDINFO\n"); \ compare(rbi.fStyle, res->bands[i].fStyle, "%x"); \ @@ -329,11 +329,11 @@ static int rbsize_numtests = 0; static void add_band_w(HWND hRebar, LPCSTR lpszText, int cxMinChild, int cx, int cxIdeal) { CHAR buffer[MAX_PATH]; - REBARBANDINFO rbi; + REBARBANDINFOA rbi; if (lpszText != NULL) strcpy(buffer, lpszText); - rbi.cbSize = sizeof(rbi); + rbi.cbSize = REBARBANDINFOA_V6_SIZE; rbi.fMask = RBBIM_SIZE | RBBIM_CHILDSIZE | RBBIM_CHILD | RBBIM_IDEALSIZE | RBBIM_TEXT; rbi.cx = cx; rbi.cxMinChild = cxMinChild; @@ -353,7 +353,7 @@ static void layout_test(void) rebuild_rebar(&hRebar); check_sizes(); - rbi.cbSize = sizeof(rbi); + rbi.cbSize = REBARBANDINFOA_V6_SIZE; rbi.fMask = RBBIM_SIZE | RBBIM_CHILDSIZE | RBBIM_CHILD; rbi.cx = 200; rbi.cxMinChild = 100; @@ -742,10 +742,10 @@ static void expect_band_content(UINT uBand, INT fStyle, COLORREF clrFore, INT cxHeader) { CHAR buf[MAX_PATH] = "abc"; - REBARBANDINFO rb; + REBARBANDINFOA rb; memset(&rb, 0xdd, sizeof(rb)); - rb.cbSize = sizeof(rb); + rb.cbSize = REBARBANDINFOA_V6_SIZE; rb.fMask = RBBIM_BACKGROUND | RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_COLORS | RBBIM_HEADERSIZE | RBBIM_ID | RBBIM_IDEALSIZE | RBBIM_IMAGE | RBBIM_LPARAM | RBBIM_SIZE | RBBIM_STYLE | RBBIM_TEXT; @@ -779,7 +779,7 @@ static void bandinfo_test(void) CHAR szABCD[] = "ABCD"; rebuild_rebar(&hRebar); - rb.cbSize = sizeof(REBARBANDINFO); + rb.cbSize = REBARBANDINFOA_V6_SIZE; rb.fMask = 0; ok(SendMessageA(hRebar, RB_INSERTBANDA, 0, (LPARAM)&rb), "RB_INSERTBAND failed\n"); expect_band_content(0, 0, 0, GetSysColor(COLOR_3DFACE), "", -1, NULL, 0, 0, 0, NULL, 0, 0xdddddddd, 0xdddddddd, 0xdddddddd, 0, 0, 0); @@ -798,7 +798,7 @@ static void bandinfo_test(void) ok(SendMessageA(hRebar, RB_SETBANDINFOA, 0, (LPARAM)&rb), "RB_SETBANDINFO failed\n"); expect_band_content(0, 0, 0, GetSysColor(COLOR_3DFACE), "ABC", -1, NULL, 15, 20, 0, NULL, 0, 0xdddddddd, 0xdddddddd, 0xdddddddd, 0, 0, 35); - rb.cbSize = sizeof(REBARBANDINFO); + rb.cbSize = REBARBANDINFOA_V6_SIZE; rb.fMask = 0; ok(SendMessageA(hRebar, RB_INSERTBANDA, 1, (LPARAM)&rb), "RB_INSERTBAND failed\n"); expect_band_content(1, 0, 0, GetSysColor(COLOR_3DFACE), "", -1, NULL, 0, 0, 0, NULL, 0, 0xdddddddd, 0xdddddddd, 0xdddddddd, 0, 0, 9); diff --git a/include/commctrl.h b/include/commctrl.h index beecb522674..8673ba9d241 100644 --- a/include/commctrl.h +++ b/include/commctrl.h @@ -2031,6 +2031,9 @@ typedef REBARBANDINFOW const *LPCREBARBANDINFOW; #define REBARBANDINFOA_V3_SIZE CCSIZEOF_STRUCT(REBARBANDINFOA, wID) #define REBARBANDINFOW_V3_SIZE CCSIZEOF_STRUCT(REBARBANDINFOW, wID) #define REBARBANDINFO_V3_SIZE CCSIZEOF_STRUCT(WINELIB_NAME_AW(REBARBANDINFO), wID) +#define REBARBANDINFOA_V6_SIZE CCSIZEOF_STRUCT(REBARBANDINFOA, cxHeader) +#define REBARBANDINFOW_V6_SIZE CCSIZEOF_STRUCT(REBARBANDINFOW, cxHeader) +#define REBARBANDINFO_V6_SIZE CCSIZEOF_STRUCT(WINELIB_NAME_AW(REBARBANDINFO), cxHeader) typedef struct tagNMREBARCHILDSIZE {