Thomas Mullaly : urlmon/tests: Added test for invalid args to IUri_GetPropertyBSTR and IUri_GetPropertyDWORD .

Alexandre Julliard julliard at winehq.org
Mon May 31 11:21:37 CDT 2010


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

Author: Thomas Mullaly <thomas.mullaly at gmail.com>
Date:   Sun May 30 11:06:10 2010 -0400

urlmon/tests: Added test for invalid args to IUri_GetPropertyBSTR and IUri_GetPropertyDWORD.

---

 dlls/urlmon/Makefile.in |    2 +-
 dlls/urlmon/tests/uri.c |   37 +++++++++++++++++++++++++++++++++++--
 dlls/urlmon/uri.c       |   20 ++++++++++++++++++++
 3 files changed, 56 insertions(+), 3 deletions(-)

diff --git a/dlls/urlmon/Makefile.in b/dlls/urlmon/Makefile.in
index 419745b..91277a5 100644
--- a/dlls/urlmon/Makefile.in
+++ b/dlls/urlmon/Makefile.in
@@ -4,7 +4,7 @@ SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = urlmon.dll
 IMPORTLIB = urlmon
-IMPORTS   = uuid ole32 rpcrt4 shlwapi wininet user32 advapi32 kernel32 ntdll
+IMPORTS   = uuid ole32 oleaut32 rpcrt4 shlwapi wininet user32 advapi32 kernel32 ntdll
 EXTRADEFS = -D_URLMON_ -DENTRY_PREFIX=URLMON_ -DPROXY_DELEGATION -DREGISTER_PROXY_DLL \
 	    -DPROXY_CLSID_IS="{0x79EAC9F1,0xBAF9,0x11CE,{0x8C,0x82,0x00,0xAA,0x00,0x4B,0xA9,0x0B}}"
 
diff --git a/dlls/urlmon/tests/uri.c b/dlls/urlmon/tests/uri.c
index 9124c1c..3142a1b 100644
--- a/dlls/urlmon/tests/uri.c
+++ b/dlls/urlmon/tests/uri.c
@@ -442,13 +442,40 @@ static void test_CreateUri_InvalidArgs(void) {
 }
 
 static void test_IUri_GetPropertyBSTR(void) {
+    IUri *uri = NULL;
+    HRESULT hr;
     DWORD i;
 
+    /* Make sure GetPropertyBSTR handles invalid args correctly. */
+    hr = pCreateUri(http_urlW, 0, 0, &uri);
+    ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
+    if(SUCCEEDED(hr)) {
+        BSTR received = NULL;
+
+        hr = IUri_GetPropertyBSTR(uri, Uri_PROPERTY_RAW_URI, NULL, 0);
+        ok(hr == E_POINTER, "Error: GetPropertyBSTR returned 0x%08x, expected 0x%08x.\n", hr, E_POINTER);
+
+        /* Make sure it handles a invalid Uri_PROPERTY's correctly. */
+        hr = IUri_GetPropertyBSTR(uri, Uri_PROPERTY_PORT, &received, 0);
+        ok(hr == S_OK, "Error: GetPropertyBSTR returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
+        ok(received != NULL, "Error: Expected the string not to be NULL.\n");
+        ok(!SysStringLen(received), "Error: Expected the string to be of len=0 but it was %d instead.\n", SysStringLen(received));
+        SysFreeString(received);
+
+        /* Make sure it handles the ZONE property correctly. */
+        received = NULL;
+        hr = IUri_GetPropertyBSTR(uri, Uri_PROPERTY_ZONE, &received, 0);
+        ok(hr == S_FALSE, "Error: GetPropertyBSTR returned 0x%08x, expected 0x%08x.\n", hr, S_FALSE);
+        ok(received != NULL, "Error: Expected the string not to be NULL.\n");
+        ok(!SysStringLen(received), "Error: Expected the string to be of len=0 but it was %d instead.\n", SysStringLen(received));
+        SysFreeString(received);
+    }
+    if(uri) IUri_Release(uri);
+
     for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
         uri_properties test = uri_tests[i];
-        HRESULT hr;
-        IUri *uri = NULL;
         LPWSTR uriW;
+        uri = NULL;
 
         uriW = a2w(test.uri);
         hr = pCreateUri(uriW, test.create_flags, 0, &uri);
@@ -505,8 +532,14 @@ static void test_IUri_GetPropertyDWORD(void) {
     hr = pCreateUri(http_urlW, 0, 0, &uri);
     ok(hr == S_OK, "Error: CreateUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
     if(SUCCEEDED(hr)) {
+        DWORD received = 0xdeadbeef;
+
         hr = IUri_GetPropertyDWORD(uri, Uri_PROPERTY_DWORD_START, NULL, 0);
         ok(hr == E_INVALIDARG, "Error: GetPropertyDWORD returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
+
+        hr = IUri_GetPropertyDWORD(uri, Uri_PROPERTY_ABSOLUTE_URI, &received, 0);
+        ok(hr == E_INVALIDARG, "Error: GetPropertyDWORD returned 0x%08x, expected 0x%08x.\n", hr, E_INVALIDARG);
+        ok(received == 0, "Error: Expected received=%d but instead received=%d.\n", 0, received);
     }
     if(uri) IUri_Release(uri);
 
diff --git a/dlls/urlmon/uri.c b/dlls/urlmon/uri.c
index 95ca907..a87bd7e 100644
--- a/dlls/urlmon/uri.c
+++ b/dlls/urlmon/uri.c
@@ -84,6 +84,21 @@ static HRESULT WINAPI Uri_GetPropertyBSTR(IUri *iface, Uri_PROPERTY uriProp, BST
 {
     Uri *This = URI_THIS(iface);
     FIXME("(%p)->(%d %p %x)\n", This, uriProp, pbstrProperty, dwFlags);
+
+    if(!pbstrProperty)
+        return E_POINTER;
+
+    if(uriProp > Uri_PROPERTY_STRING_LAST) {
+        /* Windows allocates an empty BSTR for invalid Uri_PROPERTY's. */
+        *pbstrProperty = SysAllocStringLen(NULL, 0);
+
+        /* It only returns S_FALSE for the ZONE property... */
+        if(uriProp == Uri_PROPERTY_ZONE)
+            return S_FALSE;
+        else
+            return S_OK;
+    }
+
     return E_NOTIMPL;
 }
 
@@ -120,6 +135,11 @@ static HRESULT WINAPI Uri_GetPropertyDWORD(IUri *iface, Uri_PROPERTY uriProp, DW
         return E_NOTIMPL;
     }
 
+    if(uriProp < Uri_PROPERTY_DWORD_START) {
+        *pcchProperty = 0;
+        return E_INVALIDARG;
+    }
+
     return E_NOTIMPL;
 }
 




More information about the wine-cvs mailing list