wininet: Test and fix possible error situations for InternetQueryOption with INTERNET_OPTION_PROXY.

This commit is contained in:
André Hentschel 2011-08-23 21:01:44 +02:00 committed by Alexandre Julliard
parent 535a55ec9e
commit 37cdf6bd26
2 changed files with 22 additions and 0 deletions

View File

@ -802,6 +802,7 @@ static DWORD APPINFO_QueryOption(object_header_t *hdr, DWORD option, void *buffe
}
case INTERNET_OPTION_PROXY:
if(!size) return ERROR_INVALID_PARAMETER;
if (unicode) {
INTERNET_PROXY_INFOW *pi = (INTERNET_PROXY_INFOW *)buffer;
DWORD proxyBytesRequired = 0, proxyBypassBytesRequired = 0;

View File

@ -2697,6 +2697,27 @@ static void test_options(int port)
ok(ret, "InternetQueryOption failed %u\n", GetLastError());
ok(ctx == 3, "expected 3 got %lu\n", ctx);
/* INTERNET_OPTION_PROXY */
SetLastError(0xdeadbeef);
ret = InternetQueryOptionA(ses, INTERNET_OPTION_PROXY, NULL, NULL);
error = GetLastError();
ok(!ret, "InternetQueryOption succeeded\n");
ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", error);
SetLastError(0xdeadbeef);
ret = InternetQueryOptionA(ses, INTERNET_OPTION_PROXY, &ctx, NULL);
error = GetLastError();
ok(!ret, "InternetQueryOption succeeded\n");
ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", error);
size = 0;
SetLastError(0xdeadbeef);
ret = InternetQueryOptionA(ses, INTERNET_OPTION_PROXY, NULL, &size);
error = GetLastError();
ok(!ret, "InternetQueryOption succeeded\n");
ok(error == ERROR_INSUFFICIENT_BUFFER, "expected ERROR_INSUFFICIENT_BUFFER, got %u\n", error);
ok(size >= sizeof(INTERNET_PROXY_INFOA), "expected size to be greater or equal to the struct size\n");
InternetCloseHandle(req);
InternetCloseHandle(con);
InternetCloseHandle(ses);