From: Detlef Riekenberg <wine.dev@web.de>
Subject: [PATCH 2/8] comdlg32: Validate more Parameter in PrintDlgEx
Message-Id: <1329742540-6143-3-git-send-email-wine.dev@web.de>
Date: Mon, 20 Feb 2012 13:55:34 +0100

--
By by ... Detlef
---
 dlls/comdlg32/printdlg.c |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/dlls/comdlg32/printdlg.c b/dlls/comdlg32/printdlg.c
index d074563..2647ea3 100644
--- a/dlls/comdlg32/printdlg.c
+++ b/dlls/comdlg32/printdlg.c
@@ -3781,6 +3781,20 @@ HRESULT WINAPI PrintDlgExA(LPPRINTDLGEXA lppd)
     if (!IsWindow(lppd->hwndOwner))
         return E_HANDLE;
 
+    if (lppd->nStartPage != START_PAGE_GENERAL)
+    {
+        if (!lppd->nPropertyPages)
+            return E_INVALIDARG;
+
+        FIXME("custom property sheets (%d at %p) not supported\n", lppd->nPropertyPages, lppd->lphPropertyPages);
+    }
+
+    /* Use PD_NOPAGENUMS or set nMaxPageRanges and lpPageRanges */
+    if (!(lppd->Flags & PD_NOPAGENUMS) && ((!(lppd->nMaxPageRanges) || (!lppd->lpPageRanges))))
+    {
+        return E_INVALIDARG;
+    }
+
     if (lppd->Flags & PD_RETURNDEFAULT)
     {
         PRINTER_INFO_2A *pbuf;
@@ -3905,6 +3919,20 @@ HRESULT WINAPI PrintDlgExW(LPPRINTDLGEXW lppd)
         return E_HANDLE;
     }
 
+    if (lppd->nStartPage != START_PAGE_GENERAL)
+    {
+        if (!lppd->nPropertyPages)
+            return E_INVALIDARG;
+
+        FIXME("custom property sheets (%d at %p) not supported\n", lppd->nPropertyPages, lppd->lphPropertyPages);
+    }
+
+    /* Use PD_NOPAGENUMS or set nMaxPageRanges and lpPageRanges */
+    if (!(lppd->Flags & PD_NOPAGENUMS) && ((!(lppd->nMaxPageRanges) || (!lppd->lpPageRanges))))
+    {
+        return E_INVALIDARG;
+    }
+
     if (lppd->Flags & PD_RETURNDEFAULT) {
         PRINTER_INFO_2W *pbuf;
         DRIVER_INFO_2W  *dbuf;
-- 
1.7.5.4