[PATCH resend 2/2] wininet: Return failure when adding HTTP header with empty value.

Ziqing Hui zhui at codeweavers.com
Sun Nov 21 20:25:15 CST 2021


Signed-off-by: Ziqing Hui <zhui at codeweavers.com>
---
 dlls/wininet/http.c       | 6 ++++++
 dlls/wininet/tests/http.c | 3 ---
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c
index c493137896a..9da4c8c0097 100644
--- a/dlls/wininet/http.c
+++ b/dlls/wininet/http.c
@@ -6139,6 +6139,12 @@ static DWORD HTTP_ProcessHeader(http_request_t *request, LPCWSTR field, LPCWSTR
     {
         HTTPHEADERW hdr;
 
+        if (!value[0])
+        {
+            LeaveCriticalSection(&request->headers_section);
+            return ERROR_INVALID_PARAMETER;
+        }
+
         hdr.lpszField = (LPWSTR)field;
         hdr.lpszValue = (LPWSTR)value;
         hdr.wFlags = hdr.wCount = 0;
diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c
index c3f33b4e0b7..1f261f96c9e 100644
--- a/dlls/wininet/tests/http.c
+++ b/dlls/wininet/tests/http.c
@@ -2064,8 +2064,6 @@ static void HttpHeaders_test(void)
     ok(GetLastError() == ERROR_HTTP_HEADER_NOT_FOUND, "got %u\n", GetLastError());
 
     /* Adding header with empty value should cause a failure */
-    todo_wine
-    {
     SetLastError(0xdeadbeef);
     ok(!HttpAddRequestHeadersA(hRequest, "EmptyTest1:", -1, HTTP_ADDREQ_FLAG_ADD), "Empty header should not be added.\n");
     ok(GetLastError() == ERROR_INVALID_PARAMETER, "Got unexpected error code %u.\n", GetLastError());
@@ -2087,7 +2085,6 @@ static void HttpHeaders_test(void)
     ok(!HttpQueryInfoA(hRequest, HTTP_QUERY_CUSTOM | HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer, &len, NULL),
        "Header with empty value is present.\n");
     ok(GetLastError() == ERROR_HTTP_HEADER_NOT_FOUND, "Got unexpected error code %u.\n", GetLastError());
-    }
 
     ok(InternetCloseHandle(hRequest), "Close request handle failed\n");
 done:
-- 
2.25.1




More information about the wine-devel mailing list