Jacek Caban : wininet: Return an error on redirect with no host name specified.

Alexandre Julliard julliard at winehq.org
Mon Jun 26 15:17:52 CDT 2017


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Mon Jun 26 15:36:50 2017 +0200

wininet: Return an error on redirect with no host name specified.

Inspired by Michael Müller's patch.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/wininet/http.c       |  3 +++
 dlls/wininet/tests/http.c | 25 +++++++++++++++++++++++++
 2 files changed, 28 insertions(+)

diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c
index e0bc55d..02f6609 100644
--- a/dlls/wininet/http.c
+++ b/dlls/wininet/http.c
@@ -4058,6 +4058,9 @@ static DWORD HTTP_HandleRedirect(http_request_t *request, WCHAR *url)
         urlComponents.dwUrlPathLength = 1;
         if(!InternetCrackUrlW(url, url_len, 0, &urlComponents))
             return INTERNET_GetLastError();
+
+        if(!urlComponents.dwHostNameLength)
+            return ERROR_INTERNET_INVALID_URL;
     }
 
     INTERNET_SendCallback(&request->hdr, request->hdr.dwContext, INTERNET_STATUS_REDIRECT,
diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c
index a3a0980..a2890d3 100644
--- a/dlls/wininet/tests/http.c
+++ b/dlls/wininet/tests/http.c
@@ -5269,6 +5269,31 @@ static void test_redirect(int port)
     close_connection();
     close_async_handle(req.session, 2);
 
+    trace("Test redirect to http URL with no host name...\n");
+
+    open_socket_request(port, &req);
+
+    SET_EXPECT(INTERNET_STATUS_REQUEST_COMPLETE);
+
+    server_send_string("HTTP/1.1 302 Found\r\n"
+                       "Server: winetest\r\n"
+                       "Location: http:///nohost\r\n"
+                       "Connection: keep-alive\r\n"
+                       "Content-Length: 0\r\n"
+                       "\r\n");
+
+    WaitForSingleObject(complete_event, INFINITE);
+
+    CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_COMPLETE);
+    ok(req_error == ERROR_INTERNET_INVALID_URL, "expected ERROR_INTERNET_INVALID_URL, got %u\n", req_error);
+
+    sprintf(expect_url, "http://localhost:%u/socket", port);
+    test_request_url(req.request, expect_url);
+    test_status_code(req.request, 302);
+
+    close_connection();
+    close_async_handle(req.session, 2);
+
     skip_receive_notification_tests = FALSE;
 }
 




More information about the wine-cvs mailing list