[2/2] winhttp: Accept a missing buffer when parsing a decoded URL.

Hans Leidekker hans at codeweavers.com
Tue Nov 15 02:11:27 CST 2011


Fixes http://bugs.winehq.org/show_bug.cgi?id=29074
---
 dlls/winhttp/tests/url.c |   21 ++++++++++++++++++---
 dlls/winhttp/url.c       |    2 +-
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/dlls/winhttp/tests/url.c b/dlls/winhttp/tests/url.c
index e753351..7de31f2 100644
--- a/dlls/winhttp/tests/url.c
+++ b/dlls/winhttp/tests/url.c
@@ -67,8 +67,8 @@ static const WCHAR url11[] =
      '@','w','w','w','.','w','i','n','e','h','q','.','o','r','g',':','4','4','3','/','s','i','t','e','/','a','b','o','u','t','?','q','u','e','r','y',0};
 static const WCHAR url12[] =
     {'h','t','t','p',':','/','/','e','x','a','m','p','l','e','.','n','e','t','/','p','a','t','h','?','v','a','r','1','=','e','x','a','m','p','l','e','@','e','x','a','m','p','l','e','.','c','o','m','&','v','a','r','2','=','x','&','v','a','r','3','=','y', 0};
-
-
+static const WCHAR url13[] =
+    {'h','t','t','p','s',':','/','/','t','o','o','l','s','.','g','o','o','g','l','e','.','c','o','m','/','s','e','r','v','i','c','e','/','u','p','d','a','t','e','2','?','w','=','3',':','B','x','D','H','o','W','y','8','e','z','M',0};
 
 static const WCHAR url_k1[]  =
     {'h','t','t','p',':','/','/','u','s','e','r','n','a','m','e',':','p','a','s','s','w','o','r','d',
@@ -570,7 +570,6 @@ static void WinHttpCrackUrl_test( void )
 
     reset_url_components( &uc );
     ret = WinHttpCrackUrl( url12, 0, 0, &uc);
-
     ok( ret, "WinHttpCrackUrl failed\n" );
     ok( uc.nScheme == INTERNET_SCHEME_HTTP, "unexpected scheme\n" );
     ok( uc.lpszScheme == url12,"unexpected scheme\n" );
@@ -584,6 +583,22 @@ static void WinHttpCrackUrl_test( void )
     ok( uc.dwUrlPathLength == 5, "unexpected path length\n" );
     ok( uc.lpszExtraInfo == url12 + 23, "unexpected extra info\n" );
     ok( uc.dwExtraInfoLength == 39, "unexpected extra info length\n" );
+
+    uc.lpszScheme = scheme;
+    uc.dwSchemeLength = 20;
+    uc.lpszHostName = host;
+    uc.dwHostNameLength = 20;
+    uc.lpszUserName = NULL;
+    uc.dwUserNameLength = 0;
+    uc.lpszPassword = NULL;
+    uc.dwPasswordLength = 0;
+    uc.lpszUrlPath = path;
+    uc.dwUrlPathLength = 40;
+    uc.lpszExtraInfo = NULL;
+    uc.dwExtraInfoLength = 0;
+    uc.nPort = 0;
+    ret = WinHttpCrackUrl( url13, 0, ICU_DECODE, &uc );
+    ok( ret, "WinHttpCrackUrl failed\n" );
 }
 
 START_TEST(url)
diff --git a/dlls/winhttp/url.c b/dlls/winhttp/url.c
index a662855..3938801 100644
--- a/dlls/winhttp/url.c
+++ b/dlls/winhttp/url.c
@@ -38,7 +38,7 @@ static BOOL set_component( WCHAR **str, DWORD *str_len, WCHAR *value, DWORD len,
 {
     if (!*str)
     {
-        if (len && (flags & ICU_DECODE))
+        if (len && *str_len && (flags & ICU_DECODE))
         {
             set_last_error( ERROR_INVALID_PARAMETER );
             return FALSE;
-- 
1.7.5.4






More information about the wine-patches mailing list