From bcd3ee7ab858d62beb36af9f5986544b68a3dd35 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Wed, 28 Apr 2021 16:36:56 -0500 Subject: Clean up more 32-bit assumptions. --- src/dutil/inetutil.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/dutil/inetutil.cpp') diff --git a/src/dutil/inetutil.cpp b/src/dutil/inetutil.cpp index f75849f6..8dace55f 100644 --- a/src/dutil/inetutil.cpp +++ b/src/dutil/inetutil.cpp @@ -86,7 +86,8 @@ extern "C" HRESULT DAPI InternetQueryInfoString( ) { HRESULT hr = S_OK; - DWORD_PTR cbValue = 0; + SIZE_T cbOriginal = 0; + DWORD cbValue = 0; DWORD dwIndex = 0; // If nothing was provided start off with some arbitrary size. @@ -96,10 +97,12 @@ extern "C" HRESULT DAPI InternetQueryInfoString( InetExitOnFailure(hr, "Failed to allocate memory for value."); } - hr = StrSize(*psczValue, &cbValue); + hr = StrSize(*psczValue, &cbOriginal); InetExitOnFailure(hr, "Failed to get size of value."); - if (!::HttpQueryInfoW(hRequest, dwInfo, static_cast(*psczValue), reinterpret_cast(&cbValue), &dwIndex)) + cbValue = (DWORD)min(DWORD_MAX, cbOriginal); + + if (!::HttpQueryInfoW(hRequest, dwInfo, static_cast(*psczValue), &cbValue, &dwIndex)) { DWORD er = ::GetLastError(); if (ERROR_INSUFFICIENT_BUFFER == er) @@ -109,7 +112,7 @@ extern "C" HRESULT DAPI InternetQueryInfoString( hr = StrAlloc(psczValue, cbValue / sizeof(WCHAR)); InetExitOnFailure(hr, "Failed to allocate value."); - if (!::HttpQueryInfoW(hRequest, dwInfo, static_cast(*psczValue), reinterpret_cast(&cbValue), &dwIndex)) + if (!::HttpQueryInfoW(hRequest, dwInfo, static_cast(*psczValue), &cbValue, &dwIndex)) { er = ::GetLastError(); } -- cgit v1.2.3-55-g6feb