Andrew Nguyen : urlmon: Validate parameters in MkParseDisplayNameEx.

Alexandre Julliard julliard at winehq.org
Fri May 21 12:15:22 CDT 2010


Module: wine
Branch: master
Commit: c6e5e39460549f7f255a978b71fd2ac5e4b0305c
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=c6e5e39460549f7f255a978b71fd2ac5e4b0305c

Author: Andrew Nguyen <anguyen at codeweavers.com>
Date:   Thu May 20 10:36:32 2010 -0500

urlmon: Validate parameters in MkParseDisplayNameEx.

---

 dlls/urlmon/tests/misc.c |   42 ++++++++++++++++++++++++++++++++++++++++++
 dlls/urlmon/umon.c       |    3 +++
 2 files changed, 45 insertions(+), 0 deletions(-)

diff --git a/dlls/urlmon/tests/misc.c b/dlls/urlmon/tests/misc.c
index 66d2c7e..7681b5c 100644
--- a/dlls/urlmon/tests/misc.c
+++ b/dlls/urlmon/tests/misc.c
@@ -1418,8 +1418,50 @@ static void test_MkParseDisplayNameEx(void)
             '2','0','D','0','4','F','E','0','-','3','A','E','A','-','1','0','6','9','-','A','2','D','8',
             '-','0','8','0','0','2','B','3','0','3','0','9','D',':',0};
 
+    const struct
+    {
+        LPBC *ppbc;
+        LPCWSTR szDisplayName;
+        ULONG *pchEaten;
+        LPMONIKER *ppmk;
+    } invalid_parameters[] =
+    {
+        {NULL,  NULL,     NULL,   NULL},
+        {NULL,  NULL,     NULL,   &mon},
+        {NULL,  NULL,     &eaten, NULL},
+        {NULL,  NULL,     &eaten, &mon},
+        {NULL,  wszEmpty, NULL,   NULL},
+        {NULL,  wszEmpty, NULL,   &mon},
+        {NULL,  wszEmpty, &eaten, NULL},
+        {NULL,  wszEmpty, &eaten, &mon},
+        {&bctx, NULL,     NULL,   NULL},
+        {&bctx, NULL,     NULL,   &mon},
+        {&bctx, NULL,     &eaten, NULL},
+        {&bctx, NULL,     &eaten, &mon},
+        {&bctx, wszEmpty, NULL,   NULL},
+        {&bctx, wszEmpty, NULL,   &mon},
+        {&bctx, wszEmpty, &eaten, NULL},
+        {&bctx, wszEmpty, &eaten, &mon},
+    };
+
+    int i;
+
     CreateBindCtx(0, &bctx);
 
+    for (i = 0; i < sizeof(invalid_parameters)/sizeof(invalid_parameters[0]); i++)
+    {
+        eaten = 0xdeadbeef;
+        mon = (IMoniker *)0xdeadbeef;
+        hres = MkParseDisplayNameEx(invalid_parameters[i].ppbc ? *invalid_parameters[i].ppbc : NULL,
+                                    invalid_parameters[i].szDisplayName,
+                                    invalid_parameters[i].pchEaten,
+                                    invalid_parameters[i].ppmk);
+        ok(hres == E_INVALIDARG,
+            "[%d] Expected MkParseDisplayNameEx to return E_INVALIDARG, got %08x\n", i, hres);
+        ok(eaten == 0xdeadbeef, "[%d] Expected eaten to be 0xdeadbeef, got %u\n", i, eaten);
+        ok(mon == (IMoniker *)0xdeadbeef, "[%d] Expected mon to be 0xdeadbeef, got %p\n", i, mon);
+    }
+
     hres = MkParseDisplayNameEx(bctx, url9, &eaten, &mon);
     ok(hres == S_OK, "MkParseDisplayNameEx failed: %08x\n", hres);
     ok(eaten == sizeof(url9)/sizeof(WCHAR)-1, "eaten=%d\n", eaten);
diff --git a/dlls/urlmon/umon.c b/dlls/urlmon/umon.c
index 92e902f..7ce22cc 100644
--- a/dlls/urlmon/umon.c
+++ b/dlls/urlmon/umon.c
@@ -625,6 +625,9 @@ HRESULT WINAPI MkParseDisplayNameEx(IBindCtx *pbc, LPCWSTR szDisplayName, ULONG
 {
     TRACE("(%p %s %p %p)\n", pbc, debugstr_w(szDisplayName), pchEaten, ppmk);
 
+    if (!pbc || !szDisplayName || !*szDisplayName || !pchEaten || !ppmk)
+        return E_INVALIDARG;
+
     if(is_registered_protocol(szDisplayName)) {
         HRESULT hres;
 




More information about the wine-cvs mailing list