@joebigelow / wix / commits / d8832dbc

fix stack corruption around cbdata when adding a machine certificate

chris_bednarski committed Aug 2, 2023 at 19:39 UTC d8832dbc91cd1d93ebb13c346aa0920bf44b4466
1 file changed +3 -3
src/ext/Iis/ca/scacertexec.cpp
+3 -3
@@ -154,7 +154,7 @@ static HRESULT ExecuteCertificateOperation(
154 LPWSTR pwzPFXPassword = NULL;
155 LPWSTR pwzFilePath = NULL;
156 BYTE* pbData = NULL;
157 - DWORD cbData = 0;
157 + DWORD_PTR cbData = 0;
158 DWORD_PTR cbPFXPassword = 0;
159
160 BOOL fUserStoreLocation = (CERT_SYSTEM_STORE_CURRENT_USER == dwStoreLocation);
@@ -174,7 +174,7 @@ static HRESULT ExecuteCertificateOperation(
174 ExitOnFailure(hr, "Failed to parse certificate attribute");
175 if (SCA_ACTION_INSTALL == saAction) // install operations need more data
176 {
177 - hr = WcaReadStreamFromCaData(&pwz, &pbData, (DWORD_PTR*)&cbData);
177 + hr = WcaReadStreamFromCaData(&pwz, &pbData, &cbData);
178 ExitOnFailure(hr, "Failed to parse certificate stream.");
179
180 hr = WcaReadStringFromCaData(&pwz, &pwzPFXPassword);
@@ -192,7 +192,7 @@ static HRESULT ExecuteCertificateOperation(
192 // CertAddCertificateContextToStore(CERT_STORE_ADD_REPLACE_EXISTING) does not remove the private key if the cert is replaced
193 UninstallCertificatePackage(hCertStore, fUserStoreLocation, pwzName);
194
195 - hr = InstallCertificatePackage(hCertStore, fUserStoreLocation, pwzName, pbData, cbData, iAttributes & SCA_CERT_ATTRIBUTE_VITAL, pwzPFXPassword);
195 + hr = InstallCertificatePackage(hCertStore, fUserStoreLocation, pwzName, pbData, (DWORD)cbData, iAttributes & SCA_CERT_ATTRIBUTE_VITAL, pwzPFXPassword);
196 ExitOnFailure(hr, "Failed to install certificate.");
197 }
198 else