[1/2] wininet: Test and fix possible error situations for InternetQueryOption with INTERNET_OPTION_PROXY

André Hentschel nerv at dawncrow.de
Tue Aug 23 14:01:44 CDT 2011


this patchset should be independend from the other (pending/new) patches
---
 dlls/wininet/internet.c   |    1 +
 dlls/wininet/tests/http.c |   21 +++++++++++++++++++++
 2 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/dlls/wininet/internet.c b/dlls/wininet/internet.c
index cf555c7..79ec790 100644
--- a/dlls/wininet/internet.c
+++ b/dlls/wininet/internet.c
@@ -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;
diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c
index 2110dec..f3e85cb 100644
--- a/dlls/wininet/tests/http.c
+++ b/dlls/wininet/tests/http.c
@@ -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);
-- 

Best Regards, André Hentschel



More information about the wine-patches mailing list