Erik Inge Bolsø : wininet: Add test for response without headers, avoid crash.
Alexandre Julliard
julliard at winehq.org
Wed Sep 30 10:56:07 CDT 2009
Module: wine
Branch: master
Commit: 5af1a497384dcaa42d9b9cd67c2c35ab97d73c00
URL: http://source.winehq.org/git/wine.git/?a=commit;h=5af1a497384dcaa42d9b9cd67c2c35ab97d73c00
Author: Erik Inge Bolsø <knan-wine at anduin.net>
Date: Tue Sep 29 21:50:12 2009 +0200
wininet: Add test for response without headers, avoid crash.
---
dlls/wininet/http.c | 2 +-
dlls/wininet/tests/http.c | 68 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 69 insertions(+), 1 deletions(-)
diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c
index e94e5cc..f874920 100644
--- a/dlls/wininet/http.c
+++ b/dlls/wininet/http.c
@@ -4319,7 +4319,7 @@ static INT HTTP_GetResponseHeaders(http_request_t *lpwhr, BOOL clear)
else if (!codeHundred)
{
FIXME("Non status line at head of response (%s)\n",debugstr_w(buffer));
- continue;
+ goto lend;
}
} while (codeHundred);
diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c
index dda4a41..281b4e7 100644
--- a/dlls/wininet/tests/http.c
+++ b/dlls/wininet/tests/http.c
@@ -1735,6 +1735,10 @@ static DWORD CALLBACK server_thread(LPVOID param)
send(c, okmsg, sizeof okmsg-1, 0);
send(c, page1, sizeof page1-1, 0);
}
+ if (strstr(buffer, "GET /testG"))
+ {
+ send(c, page1, sizeof page1-1, 0);
+ }
shutdown(c, 2);
closesocket(c);
@@ -2218,6 +2222,69 @@ static void test_invalid_response_headers(int port)
InternetCloseHandle(session);
}
+static void test_response_without_headers(int port)
+{
+ HINTERNET hi, hc, hr;
+ DWORD r, count, size, status;
+ char buffer[1024];
+
+ SetLastError(0xdeadbeef);
+ hi = InternetOpen(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
+ ok(hi != NULL, "open failed %u\n", GetLastError());
+
+ SetLastError(0xdeadbeef);
+ hc = InternetConnect(hi, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
+ ok(hc != NULL, "connect failed %u\n", GetLastError());
+
+ SetLastError(0xdeadbeef);
+ hr = HttpOpenRequest(hc, NULL, "/testG", NULL, NULL, NULL, 0, 0);
+ ok(hr != NULL, "HttpOpenRequest failed %u\n", GetLastError());
+
+ SetLastError(0xdeadbeef);
+ r = HttpSendRequest(hr, NULL, 0, NULL, 0);
+ todo_wine ok(r, "HttpSendRequest failed %u\n", GetLastError());
+
+ count = 0;
+ memset(buffer, 0, sizeof buffer);
+ SetLastError(0xdeadbeef);
+ r = InternetReadFile(hr, buffer, sizeof buffer, &count);
+ ok(r, "InternetReadFile failed %u\n", GetLastError());
+ todo_wine ok(count == sizeof page1 - 1, "count was wrong\n");
+ todo_wine ok(!memcmp(buffer, page1, sizeof page1), "http data wrong\n");
+
+ status = 0;
+ size = sizeof(status);
+ SetLastError(0xdeadbeef);
+ r = HttpQueryInfo(hr, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &status, &size, NULL );
+ todo_wine ok(r, "HttpQueryInfo failed %u\n", GetLastError());
+ todo_wine ok(status == 200, "expected status 200 got %u\n", status);
+
+ buffer[0] = 0;
+ size = sizeof(buffer);
+ SetLastError(0xdeadbeef);
+ r = HttpQueryInfo(hr, HTTP_QUERY_STATUS_TEXT, buffer, &size, NULL );
+ todo_wine ok(r, "HttpQueryInfo failed %u\n", GetLastError());
+ todo_wine ok(!strcmp(buffer, "OK"), "expected OK got: \"%s\"\n", buffer);
+
+ buffer[0] = 0;
+ size = sizeof(buffer);
+ SetLastError(0xdeadbeef);
+ r = HttpQueryInfo(hr, HTTP_QUERY_VERSION, buffer, &size, NULL);
+ ok(r, "HttpQueryInfo failed %u\n", GetLastError());
+ todo_wine ok(!strcmp(buffer, "HTTP/1.0"), "expected HTTP/1.0 got: \"%s\"\n", buffer);
+
+ buffer[0] = 0;
+ size = sizeof(buffer);
+ SetLastError(0xdeadbeef);
+ r = HttpQueryInfo(hr, HTTP_QUERY_RAW_HEADERS, buffer, &size, NULL);
+ ok(r, "HttpQueryInfo failed %u\n", GetLastError());
+ todo_wine ok(!strcmp(buffer, "HTTP/1.0 200 OK"), "raw headers wrong: \"%s\"\n", buffer);
+
+ InternetCloseHandle(hr);
+ InternetCloseHandle(hc);
+ InternetCloseHandle(hi);
+}
+
static void test_HttpQueryInfo(int port)
{
HINTERNET hi, hc, hr;
@@ -2353,6 +2420,7 @@ static void test_http_connection(void)
test_cookie_header(si.port);
test_basic_authentication(si.port);
test_invalid_response_headers(si.port);
+ test_response_without_headers(si.port);
test_HttpQueryInfo(si.port);
test_HttpSendRequestW(si.port);
More information about the wine-cvs
mailing list