aboutsummaryrefslogtreecommitdiff
path: root/src/dutil/inetutil.cpp
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2021-04-28 16:36:56 -0500
committerSean Hall <r.sean.hall@gmail.com>2021-04-29 13:58:14 -0500
commitbcd3ee7ab858d62beb36af9f5986544b68a3dd35 (patch)
tree424c4e61a580b7c4b7481712f69ab0193d76b9c4 /src/dutil/inetutil.cpp
parentd73c29407fe5ec6a0207af7d9c2547457ae0854c (diff)
downloadwix-bcd3ee7ab858d62beb36af9f5986544b68a3dd35.tar.gz
wix-bcd3ee7ab858d62beb36af9f5986544b68a3dd35.tar.bz2
wix-bcd3ee7ab858d62beb36af9f5986544b68a3dd35.zip
Clean up more 32-bit assumptions.
Diffstat (limited to 'src/dutil/inetutil.cpp')
-rw-r--r--src/dutil/inetutil.cpp11
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 }