From 7d487c914f7e2ab9971f7b39d66a0b2e3a2edeba Mon Sep 17 00:00:00 2001 From: Adrian Thurston Date: Sat, 13 Nov 1999 20:49:12 +0000 Subject: [PATCH] Added validations for page index before using it. --- dlls/comctl32/propsheet.c | 47 +++++++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/dlls/comctl32/propsheet.c b/dlls/comctl32/propsheet.c index 73871ca5c15..4aa2649f0a1 100644 --- a/dlls/comctl32/propsheet.c +++ b/dlls/comctl32/propsheet.c @@ -1021,6 +1021,9 @@ static BOOL PROPSHEET_Back(HWND hwndDlg) PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwndDlg, PropSheetInfoStr); + if (psInfo->active_page <= 0) + return FALSE; + hdr.hwndFrom = hwndDlg; hdr.code = PSN_WIZBACK; @@ -1053,6 +1056,9 @@ static BOOL PROPSHEET_Next(HWND hwndDlg) PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwndDlg, PropSheetInfoStr); + if (psInfo->active_page < 0 || psInfo->active_page == psInfo->nPages - 1) + return FALSE; + hdr.hwndFrom = hwndDlg; hdr.code = PSN_WIZNEXT; @@ -1084,6 +1090,9 @@ static BOOL PROPSHEET_Finish(HWND hwndDlg) PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwndDlg, PropSheetInfoStr); + if (psInfo->active_page < 0) + return FALSE; + hdr.hwndFrom = hwndDlg; hdr.code = PSN_WIZFINISH; @@ -1116,6 +1125,9 @@ static BOOL PROPSHEET_Apply(HWND hwndDlg) PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwndDlg, PropSheetInfoStr); + if (psInfo->active_page < 0) + return FALSE; + hdr.hwndFrom = hwndDlg; /* @@ -1152,9 +1164,13 @@ static void PROPSHEET_Cancel(HWND hwndDlg) { PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwndDlg, PropSheetInfoStr); - HWND hwndPage = psInfo->proppage[psInfo->active_page].hwndPage; + HWND hwndPage; NMHDR hdr; + if (psInfo->active_page < 0) + return; + + hwndPage = psInfo->proppage[psInfo->active_page].hwndPage; hdr.hwndFrom = hwndDlg; hdr.code = PSN_QUERYCANCEL; @@ -1178,9 +1194,13 @@ static void PROPSHEET_Help(HWND hwndDlg) { PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwndDlg, PropSheetInfoStr); - HWND hwndPage = psInfo->proppage[psInfo->active_page].hwndPage; + HWND hwndPage; NMHDR hdr; + if (psInfo->active_page < 0) + return; + + hwndPage = psInfo->proppage[psInfo->active_page].hwndPage; hdr.hwndFrom = hwndDlg; hdr.code = PSN_HELP; @@ -1301,9 +1321,8 @@ static BOOL PROPSHEET_CanSetCurSel(HWND hwndDlg) HWND hwndPage; NMHDR hdr; - if (!psInfo) - return FALSE; - + if (!psInfo || psInfo->active_page < 0) + return FALSE; /* * Notify the current page. */ @@ -1328,6 +1347,9 @@ static BOOL PROPSHEET_SetCurSel(HWND hwndDlg, HWND hwndHelp = GetDlgItem(hwndDlg, IDHELP); NMHDR hdr; + if (psInfo->active_page < 0) + return FALSE; + hwndPage = psInfo->proppage[psInfo->active_page].hwndPage; hdr.hwndFrom = hwndDlg; @@ -1335,14 +1357,12 @@ static BOOL PROPSHEET_SetCurSel(HWND hwndDlg, * hpage takes precedence over index. */ if (hpage != NULL) - { index = PROPSHEET_GetPageIndex(hpage, psInfo); - if (index == -1) - { - TRACE("Could not find page to remove!\n"); - return FALSE; - } + if (index < 0 || index >= psInfo->nPages) + { + TRACE("Could not find page to select!\n"); + return FALSE; } hwndPage = psInfo->proppage[index].hwndPage; @@ -1804,6 +1824,8 @@ PROPSHEET_DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) HWND hwndTabCtrl = GetDlgItem(hwnd, IDC_TABCONTROL); LPCPROPSHEETPAGEA ppshpage; + SetPropA(hwnd, PropSheetInfoStr, (HANDLE)psInfo); + /* * Small icon in the title bar. */ @@ -1868,9 +1890,6 @@ PROPSHEET_DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) if (!(psInfo->ppshheader->dwFlags & PSH_WIZARD)) SendMessageA(hwndTabCtrl, TCM_SETCURSEL, psInfo->active_page, 0); - SetPropA(hwnd, PropSheetInfoStr, (HANDLE)psInfo); - - if (!HIWORD(psInfo->ppshheader->pszCaption) && psInfo->ppshheader->hInstance) {