From: Paul Gofman <pgofman(a)codeweavers.com> --- dlls/wininet/internet.c | 7 +++++++ dlls/wininet/tests/http.c | 16 ++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/dlls/wininet/internet.c b/dlls/wininet/internet.c index 764be89189d..17a7ce9385e 100644 --- a/dlls/wininet/internet.c +++ b/dlls/wininet/internet.c @@ -2607,6 +2607,13 @@ BOOL WINAPI InternetReadFile(HINTERNET hFile, LPVOID lpBuffer, TRACE("%p %p %ld %p\n", hFile, lpBuffer, dwNumOfBytesToRead, pdwNumOfBytesRead); + if (!lpBuffer || !pdwNumOfBytesRead) + { + INTERNET_SetLastError(ERROR_INVALID_PARAMETER); + if (pdwNumOfBytesRead) *pdwNumOfBytesRead = 0; + return FALSE; + } + hdr = get_handle_object(hFile); if (!hdr) { INTERNET_SetLastError(ERROR_INVALID_HANDLE); diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c index 14c08e0c0ad..bc18986c69f 100644 --- a/dlls/wininet/tests/http.c +++ b/dlls/wininet/tests/http.c @@ -1137,6 +1137,22 @@ static void InternetReadFile_test(int flags, const test_data_t *test) "InternetReadFile should have set last error to ERROR_INVALID_HANDLE instead of %lu\n", GetLastError()); + SetLastError(0xdeadbeef); + res = InternetReadFile(hor, buffer, 100, NULL); + ok(!res && GetLastError() == ERROR_INVALID_PARAMETER, "got res %d, error %lu.\n", res, GetLastError()); + + SetLastError(0xdeadbeef); + length = 0xdeadbeef; + res = InternetReadFile(hor, NULL, 100, &length); + ok(!res && GetLastError() == ERROR_INVALID_PARAMETER, "got res %d, error %lu.\n", res, GetLastError()); + ok(!length, "got %lu.\n", length); + + SetLastError(0xdeadbeef); + length = 0xdeadbeef; + res = InternetReadFile(hor, NULL, 0, &length); + ok(!res && GetLastError() == ERROR_INVALID_PARAMETER, "got res %d, error %lu.\n", res, GetLastError()); + ok(!length, "got %lu.\n", length); + length = 100; if(winetest_debug > 1) trace("Entering Query loop\n"); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/6638