Sebastian Lackner : wininet: Don' t update *lpdwIndex if HttpQueryInfoW fails with ERROR_INSUFFICIENT_BUFFER.
Alexandre Julliard
julliard at winehq.org
Wed Jun 18 14:31:41 CDT 2014
Module: wine
Branch: master
Commit: 2e0921d065121fe4bf3b17a54ab529f3fd4041fd
URL: http://source.winehq.org/git/wine.git/?a=commit;h=2e0921d065121fe4bf3b17a54ab529f3fd4041fd
Author: Sebastian Lackner <sebastian at fds-team.de>
Date: Tue Jun 17 02:57:10 2014 +0200
wininet: Don't update *lpdwIndex if HttpQueryInfoW fails with ERROR_INSUFFICIENT_BUFFER.
---
dlls/wininet/http.c | 3 +--
dlls/wininet/tests/http.c | 17 +++++++++++++++--
2 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c
index c7e3474..d2b3de9 100644
--- a/dlls/wininet/http.c
+++ b/dlls/wininet/http.c
@@ -3695,8 +3695,6 @@ static DWORD HTTP_HttpQueryInfoW(http_request_t *request, DWORD dwInfoLevel,
return ERROR_HTTP_HEADER_NOT_FOUND;
}
- if (lpdwIndex) (*lpdwIndex)++;
-
/* coalesce value to requested type */
if (dwInfoLevel & HTTP_QUERY_FLAG_NUMBER && lpBuffer)
{
@@ -3742,6 +3740,7 @@ static DWORD HTTP_HttpQueryInfoW(http_request_t *request, DWORD dwInfoLevel,
}
*lpdwBufferLength = len - sizeof(WCHAR);
}
+ if (lpdwIndex) (*lpdwIndex)++;
return ERROR_SUCCESS;
}
diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c
index 41f4c5b..f3340df 100644
--- a/dlls/wininet/tests/http.c
+++ b/dlls/wininet/tests/http.c
@@ -465,7 +465,7 @@ static void InternetReadFile_test(int flags, const test_data_t *test)
char *post_data = NULL;
BOOL res, on_async = TRUE;
CHAR buffer[4000];
- DWORD length, exlen = 0, post_len = 0;
+ DWORD length, index, exlen = 0, post_len = 0;
const char *types[2] = { "*", NULL };
HINTERNET hi, hic = 0, hor = 0;
@@ -635,12 +635,23 @@ static void InternetReadFile_test(int flags, const test_data_t *test)
ok(res, "InternetQueryOptionA(INTERNET_OPTION_URL) failed: %u\n", GetLastError());
ok(!strcmp(buffer, test->redirected_url), "Wrong URL %s\n", buffer);
+ index = 0;
+ length = 0;
+ SetLastError(0xdeadbeef);
+ ok(HttpQueryInfoA(hor,HTTP_QUERY_CONTENT_LENGTH,NULL,&length,&index) == FALSE,"Query worked\n");
+ if(test->flags & TESTF_COMPRESSED)
+ ok(GetLastError() == ERROR_HTTP_HEADER_NOT_FOUND,
+ "expected ERROR_HTTP_HEADER_NOT_FOUND, got %u\n", GetLastError());
+ ok(index == 0, "Index was incremented\n");
+
+ index = 0;
length = 16;
- res = HttpQueryInfoA(hor,HTTP_QUERY_CONTENT_LENGTH,&buffer,&length,0x0);
+ res = HttpQueryInfoA(hor,HTTP_QUERY_CONTENT_LENGTH,&buffer,&length,&index);
trace("Option HTTP_QUERY_CONTENT_LENGTH -> %i %s (%u)\n",res,buffer,GetLastError());
if(test->flags & TESTF_COMPRESSED)
ok(!res && GetLastError() == ERROR_HTTP_HEADER_NOT_FOUND,
"expected ERROR_HTTP_HEADER_NOT_FOUND, got %x (%u)\n", res, GetLastError());
+ ok(!res || index == 1, "Index was not incremented although result is %x (index = %u)\n", res, index);
length = 100;
res = HttpQueryInfoA(hor,HTTP_QUERY_CONTENT_TYPE,buffer,&length,0x0);
@@ -1594,6 +1605,8 @@ static void HttpHeaders_test(void)
strcpy(buffer,"Warning");
ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS,
buffer,&len,&index) == FALSE,"Query succeeded on a too small buffer\n");
+ ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Unexpected last error: %d\n", GetLastError());
+ ok(index == 0, "Index was incremented\n");
ok(strcmp(buffer,"Warning")==0, "incorrect string was returned(%s)\n",buffer); /* string not touched */
ok(len == 6, "Invalid length (exp. 6, got %d)\n", len); /* unlike success, the length includes the NULL-terminator */
More information about the wine-cvs
mailing list