[PATCH 1/2] comctl32/propsheet: Enforce minimal PROPSHEETPAGE structure size when creating a page

Nikolay Sivov nsivov at codeweavers.com
Wed Mar 1 13:47:20 CST 2017


Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
 dlls/comctl32/propsheet.c       | 12 ++++++++++--
 dlls/comctl32/tests/propsheet.c |  2 --
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/dlls/comctl32/propsheet.c b/dlls/comctl32/propsheet.c
index a3a6a5c4df..88a44cd15d 100644
--- a/dlls/comctl32/propsheet.c
+++ b/dlls/comctl32/propsheet.c
@@ -2957,8 +2957,12 @@ static LPWSTR load_string( HINSTANCE instance, LPCWSTR str )
 HPROPSHEETPAGE WINAPI CreatePropertySheetPageA(
                           LPCPROPSHEETPAGEA lpPropSheetPage)
 {
-  PROPSHEETPAGEW* ppsp = Alloc(sizeof(PROPSHEETPAGEW));
+    PROPSHEETPAGEW *ppsp;
 
+    if (lpPropSheetPage->dwSize < PROPSHEETPAGEA_V1_SIZE)
+        return NULL;
+
+    ppsp = Alloc(sizeof(PROPSHEETPAGEW));
   memcpy(ppsp,lpPropSheetPage,min(lpPropSheetPage->dwSize,sizeof(PROPSHEETPAGEA)));
 
   ppsp->dwFlags &= ~ PSP_INTERNAL_UNICODE;
@@ -3023,8 +3027,12 @@ HPROPSHEETPAGE WINAPI CreatePropertySheetPageA(
  */
 HPROPSHEETPAGE WINAPI CreatePropertySheetPageW(LPCPROPSHEETPAGEW lpPropSheetPage)
 {
-  PROPSHEETPAGEW* ppsp = Alloc(sizeof(PROPSHEETPAGEW));
+    PROPSHEETPAGEW *ppsp;
+
+    if (lpPropSheetPage->dwSize < PROPSHEETPAGEW_V1_SIZE)
+        return NULL;
 
+    ppsp = Alloc(sizeof(PROPSHEETPAGEW));
   memcpy(ppsp,lpPropSheetPage,min(lpPropSheetPage->dwSize,sizeof(PROPSHEETPAGEW)));
 
   ppsp->dwFlags |= PSP_INTERNAL_UNICODE;
diff --git a/dlls/comctl32/tests/propsheet.c b/dlls/comctl32/tests/propsheet.c
index 0b1c45c5a2..8a4e6d187c 100644
--- a/dlls/comctl32/tests/propsheet.c
+++ b/dlls/comctl32/tests/propsheet.c
@@ -1076,7 +1076,6 @@ static void test_CreatePropertySheetPage(void)
         hpsp = CreatePropertySheetPageA(&page.u.pageA);
 
         if (page.u.pageA.dwSize < PROPSHEETPAGEA_V1_SIZE)
-        todo_wine
             ok(hpsp == NULL, "Expected failure, size %u\n", page.u.pageA.dwSize);
         else
         {
@@ -1108,7 +1107,6 @@ static void test_CreatePropertySheetPage(void)
         hpsp = CreatePropertySheetPageW(&page.u.pageW);
 
         if (page.u.pageW.dwSize < PROPSHEETPAGEW_V1_SIZE)
-        todo_wine
             ok(hpsp == NULL, "Expected failure, size %u\n", page.u.pageW.dwSize);
         else
         {
-- 
2.11.0




More information about the wine-patches mailing list