diff options
Diffstat (limited to 'src/dutil/inetutil.cpp')
| -rw-r--r-- | src/dutil/inetutil.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
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( | |||
| 86 | ) | 86 | ) |
| 87 | { | 87 | { |
| 88 | HRESULT hr = S_OK; | 88 | HRESULT hr = S_OK; |
| 89 | DWORD_PTR cbValue = 0; | 89 | SIZE_T cbOriginal = 0; |
| 90 | DWORD cbValue = 0; | ||
| 90 | DWORD dwIndex = 0; | 91 | DWORD dwIndex = 0; |
| 91 | 92 | ||
| 92 | // If nothing was provided start off with some arbitrary size. | 93 | // If nothing was provided start off with some arbitrary size. |
| @@ -96,10 +97,12 @@ extern "C" HRESULT DAPI InternetQueryInfoString( | |||
| 96 | InetExitOnFailure(hr, "Failed to allocate memory for value."); | 97 | InetExitOnFailure(hr, "Failed to allocate memory for value."); |
| 97 | } | 98 | } |
| 98 | 99 | ||
| 99 | hr = StrSize(*psczValue, &cbValue); | 100 | hr = StrSize(*psczValue, &cbOriginal); |
| 100 | InetExitOnFailure(hr, "Failed to get size of value."); | 101 | InetExitOnFailure(hr, "Failed to get size of value."); |
| 101 | 102 | ||
| 102 | if (!::HttpQueryInfoW(hRequest, dwInfo, static_cast<void*>(*psczValue), reinterpret_cast<DWORD*>(&cbValue), &dwIndex)) | 103 | cbValue = (DWORD)min(DWORD_MAX, cbOriginal); |
| 104 | |||
| 105 | if (!::HttpQueryInfoW(hRequest, dwInfo, static_cast<void*>(*psczValue), &cbValue, &dwIndex)) | ||
| 103 | { | 106 | { |
| 104 | DWORD er = ::GetLastError(); | 107 | DWORD er = ::GetLastError(); |
| 105 | if (ERROR_INSUFFICIENT_BUFFER == er) | 108 | if (ERROR_INSUFFICIENT_BUFFER == er) |
| @@ -109,7 +112,7 @@ extern "C" HRESULT DAPI InternetQueryInfoString( | |||
| 109 | hr = StrAlloc(psczValue, cbValue / sizeof(WCHAR)); | 112 | hr = StrAlloc(psczValue, cbValue / sizeof(WCHAR)); |
| 110 | InetExitOnFailure(hr, "Failed to allocate value."); | 113 | InetExitOnFailure(hr, "Failed to allocate value."); |
| 111 | 114 | ||
| 112 | if (!::HttpQueryInfoW(hRequest, dwInfo, static_cast<void*>(*psczValue), reinterpret_cast<DWORD*>(&cbValue), &dwIndex)) | 115 | if (!::HttpQueryInfoW(hRequest, dwInfo, static_cast<void*>(*psczValue), &cbValue, &dwIndex)) |
| 113 | { | 116 | { |
| 114 | er = ::GetLastError(); | 117 | er = ::GetLastError(); |
| 115 | } | 118 | } |
