In HttpSendRequestW and HttpSendRequestExW, if the header pointer is not null but the length parameter is 0, the header length should be derived from the string length instead.
In HttpSendRequestA and HttpSendRequestExA, on the same scenario, the function should fail instead.
From: Hans Lehnert hans.lehnert@gmail.com
In HttpSendRequestW and HttpSendRequestExW, if the header pointer is not null but the length parameter is 0, the header length should be derived from the string length instead.
In HttpSendRequestA and HttpSendRequestExA, on the same scenario, the function should fail instead. --- dlls/wininet/http.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c index b646ddf5b69..ec3b75d4663 100644 --- a/dlls/wininet/http.c +++ b/dlls/wininet/http.c @@ -5043,8 +5043,13 @@ static DWORD HTTP_HttpSendRequestW(http_request_t *request, LPCWSTR lpszHeaders, }
/* add the headers the caller supplied */ - if( lpszHeaders && dwHeaderLength ) + if (lpszHeaders) + { + if (dwHeaderLength == 0) + dwHeaderLength = lstrlenW(lpszHeaders); + HTTP_HttpAddRequestHeadersW(request, lpszHeaders, dwHeaderLength, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE); + }
do { @@ -5551,6 +5556,12 @@ BOOL WINAPI HttpSendRequestExA(HINTERNET hRequest, BuffersInW.dwStructSize = sizeof(LPINTERNET_BUFFERSW); if (lpBuffersIn->lpcszHeader) { + if (lpBuffersIn->dwHeadersLength == 0) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + headerlen = MultiByteToWideChar(CP_ACP,0,lpBuffersIn->lpcszHeader, lpBuffersIn->dwHeadersLength,0,0); header = malloc(headerlen * sizeof(WCHAR)); @@ -5773,6 +5784,12 @@ BOOL WINAPI HttpSendRequestA(HINTERNET hHttpRequest, LPCSTR lpszHeaders, DWORD nLen=dwHeaderLength; if(lpszHeaders!=NULL) { + if (dwHeaderLength == 0) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + nLen=MultiByteToWideChar(CP_ACP,0,lpszHeaders,dwHeaderLength,NULL,0); szHeaders = malloc(nLen * sizeof(WCHAR)); MultiByteToWideChar(CP_ACP,0,lpszHeaders,dwHeaderLength,szHeaders,nLen);