From f70c9ae8d147ac2f4377dae1f90eacf18d05df91 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Mon, 16 May 2016 22:42:19 +0200 Subject: [PATCH] wininet: Fixed handing NULL buffer in InternetReadFileExW. Signed-off-by: Jacek Caban Signed-off-by: Alexandre Julliard --- dlls/wininet/internet.c | 2 +- dlls/wininet/tests/http.c | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/dlls/wininet/internet.c b/dlls/wininet/internet.c index 53597944a99..e192592693a 100644 --- a/dlls/wininet/internet.c +++ b/dlls/wininet/internet.c @@ -2280,7 +2280,7 @@ BOOL WINAPI InternetReadFileExW(HINTERNET hFile, LPINTERNET_BUFFERSW lpBuffer, TRACE("(%p %p 0x%x 0x%lx)\n", hFile, lpBuffer, dwFlags, dwContext); - if (lpBuffer->dwStructSize != sizeof(*lpBuffer)) { + if (!lpBuffer || lpBuffer->dwStructSize != sizeof(*lpBuffer)) { SetLastError(ERROR_INVALID_PARAMETER); return FALSE; } diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c index b4cad7d15ba..78cec504564 100644 --- a/dlls/wininet/tests/http.c +++ b/dlls/wininet/tests/http.c @@ -1067,6 +1067,11 @@ static void InternetReadFileExA_test(int flags) CLEAR_NOTIFIED(INTERNET_STATUS_CONNECTING_TO_SERVER); CLEAR_NOTIFIED(INTERNET_STATUS_CONNECTED_TO_SERVER); + rc = InternetReadFileExW(hor, NULL, 0, 0xdeadcafe); + ok(!rc && (GetLastError() == ERROR_INVALID_PARAMETER), + "InternetReadFileEx should have failed with ERROR_INVALID_PARAMETER instead of %s, %u\n", + rc ? "TRUE" : "FALSE", GetLastError()); + /* tests invalid dwStructSize */ inetbuffers.dwStructSize = sizeof(inetbuffers)+1; inetbuffers.lpcszHeader = NULL;