diff options
author | Sean Hall <r.sean.hall@gmail.com> | 2022-05-26 17:34:07 -0500 |
---|---|---|
committer | Sean Hall <r.sean.hall@gmail.com> | 2022-05-31 13:20:44 -0500 |
commit | a070d8c7b57d6c9a54106abeb359a6c868b6d7ae (patch) | |
tree | 5236359530757a11395580cf8775ffea90c912d0 /src/burn/engine/payload.cpp | |
parent | dea25f58e6119ef1acc5c5cc2a7c98e52cdff519 (diff) | |
download | wix-a070d8c7b57d6c9a54106abeb359a6c868b6d7ae.tar.gz wix-a070d8c7b57d6c9a54106abeb359a6c868b6d7ae.tar.bz2 wix-a070d8c7b57d6c9a54106abeb359a6c868b6d7ae.zip |
Update payload.cpp and container.cpp to use more concise Exit* macros.
Diffstat (limited to 'src/burn/engine/payload.cpp')
-rw-r--r-- | src/burn/engine/payload.cpp | 65 |
1 files changed, 31 insertions, 34 deletions
diff --git a/src/burn/engine/payload.cpp b/src/burn/engine/payload.cpp index e0362a76..6acfcd73 100644 --- a/src/burn/engine/payload.cpp +++ b/src/burn/engine/payload.cpp | |||
@@ -23,6 +23,7 @@ extern "C" HRESULT PayloadsParseFromXml( | |||
23 | BOOL fChainPayload = pContainers && pLayoutPayloads; // These are required when parsing chain payloads. | 23 | BOOL fChainPayload = pContainers && pLayoutPayloads; // These are required when parsing chain payloads. |
24 | BOOL fValidFileSize = FALSE; | 24 | BOOL fValidFileSize = FALSE; |
25 | size_t cByteOffset = fChainPayload ? offsetof(BURN_PAYLOAD, sczKey) : offsetof(BURN_PAYLOAD, sczSourcePath); | 25 | size_t cByteOffset = fChainPayload ? offsetof(BURN_PAYLOAD, sczKey) : offsetof(BURN_PAYLOAD, sczSourcePath); |
26 | BOOL fXmlFound = FALSE; | ||
26 | 27 | ||
27 | // select payload nodes | 28 | // select payload nodes |
28 | hr = XmlSelectNodes(pixnBundle, L"Payload", &pixnNodes); | 29 | hr = XmlSelectNodes(pixnBundle, L"Payload", &pixnNodes); |
@@ -58,15 +59,15 @@ extern "C" HRESULT PayloadsParseFromXml( | |||
58 | 59 | ||
59 | // @Id | 60 | // @Id |
60 | hr = XmlGetAttributeEx(pixnNode, L"Id", &pPayload->sczKey); | 61 | hr = XmlGetAttributeEx(pixnNode, L"Id", &pPayload->sczKey); |
61 | ExitOnFailure(hr, "Failed to get @Id."); | 62 | ExitOnRequiredXmlQueryFailure(hr, "Failed to get @Id."); |
62 | 63 | ||
63 | // @FilePath | 64 | // @FilePath |
64 | hr = XmlGetAttributeEx(pixnNode, L"FilePath", &pPayload->sczFilePath); | 65 | hr = XmlGetAttributeEx(pixnNode, L"FilePath", &pPayload->sczFilePath); |
65 | ExitOnFailure(hr, "Failed to get @FilePath."); | 66 | ExitOnRequiredXmlQueryFailure(hr, "Failed to get @FilePath."); |
66 | 67 | ||
67 | // @SourcePath | 68 | // @SourcePath |
68 | hr = XmlGetAttributeEx(pixnNode, L"SourcePath", &pPayload->sczSourcePath); | 69 | hr = XmlGetAttributeEx(pixnNode, L"SourcePath", &pPayload->sczSourcePath); |
69 | ExitOnFailure(hr, "Failed to get @SourcePath."); | 70 | ExitOnRequiredXmlQueryFailure(hr, "Failed to get @SourcePath."); |
70 | 71 | ||
71 | if (!fChainPayload) | 72 | if (!fChainPayload) |
72 | { | 73 | { |
@@ -77,7 +78,7 @@ extern "C" HRESULT PayloadsParseFromXml( | |||
77 | { | 78 | { |
78 | // @Packaging | 79 | // @Packaging |
79 | hr = XmlGetAttributeEx(pixnNode, L"Packaging", &scz); | 80 | hr = XmlGetAttributeEx(pixnNode, L"Packaging", &scz); |
80 | ExitOnFailure(hr, "Failed to get @Packaging."); | 81 | ExitOnRequiredXmlQueryFailure(hr, "Failed to get @Packaging."); |
81 | 82 | ||
82 | if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, scz, -1, L"embedded", -1)) | 83 | if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, scz, -1, L"embedded", -1)) |
83 | { | 84 | { |
@@ -89,43 +90,40 @@ extern "C" HRESULT PayloadsParseFromXml( | |||
89 | } | 90 | } |
90 | else | 91 | else |
91 | { | 92 | { |
92 | hr = E_INVALIDARG; | 93 | ExitWithRootFailure(hr, E_INVALIDARG, "Invalid value for @Packaging: %ls", scz); |
93 | ExitOnFailure(hr, "Invalid value for @Packaging: %ls", scz); | ||
94 | } | 94 | } |
95 | 95 | ||
96 | // @Container | 96 | // @Container |
97 | hr = XmlGetAttributeEx(pixnNode, L"Container", &scz); | 97 | hr = XmlGetAttributeEx(pixnNode, L"Container", &scz); |
98 | if (E_NOTFOUND != hr || BURN_PAYLOAD_PACKAGING_EMBEDDED == pPayload->packaging) | 98 | ExitOnOptionalXmlQueryFailure(hr, fXmlFound, "Failed to get @Container."); |
99 | { | ||
100 | ExitOnFailure(hr, "Failed to get @Container."); | ||
101 | 99 | ||
100 | if (fXmlFound) | ||
101 | { | ||
102 | // find container | 102 | // find container |
103 | hr = ContainerFindById(pContainers, scz, &pPayload->pContainer); | 103 | hr = ContainerFindById(pContainers, scz, &pPayload->pContainer); |
104 | ExitOnFailure(hr, "Failed to to find container: %ls", scz); | 104 | ExitOnFailure(hr, "Failed to find container: %ls", scz); |
105 | 105 | ||
106 | pPayload->pContainer->cParsedPayloads += 1; | 106 | pPayload->pContainer->cParsedPayloads += 1; |
107 | } | 107 | } |
108 | else if (BURN_PAYLOAD_PACKAGING_EMBEDDED == pPayload->packaging) | ||
109 | { | ||
110 | ExitWithRootFailure(hr, E_NOTFOUND, "@Container is required for embedded payload."); | ||
111 | } | ||
108 | 112 | ||
109 | // @LayoutOnly | 113 | // @LayoutOnly |
110 | hr = XmlGetYesNoAttribute(pixnNode, L"LayoutOnly", &pPayload->fLayoutOnly); | 114 | hr = XmlGetYesNoAttribute(pixnNode, L"LayoutOnly", &pPayload->fLayoutOnly); |
111 | if (E_NOTFOUND != hr) | 115 | ExitOnOptionalXmlQueryFailure(hr, fXmlFound, "Failed to get @LayoutOnly."); |
112 | { | ||
113 | ExitOnFailure(hr, "Failed to get @LayoutOnly."); | ||
114 | } | ||
115 | 116 | ||
116 | // @DownloadUrl | 117 | // @DownloadUrl |
117 | hr = XmlGetAttributeEx(pixnNode, L"DownloadUrl", &pPayload->downloadSource.sczUrl); | 118 | hr = XmlGetAttributeEx(pixnNode, L"DownloadUrl", &pPayload->downloadSource.sczUrl); |
118 | if (E_NOTFOUND != hr) | 119 | ExitOnOptionalXmlQueryFailure(hr, fXmlFound, "Failed to get @DownloadUrl."); |
119 | { | ||
120 | ExitOnFailure(hr, "Failed to get @DownloadUrl."); | ||
121 | } | ||
122 | 120 | ||
123 | // @FileSize | 121 | // @FileSize |
124 | hr = XmlGetAttributeEx(pixnNode, L"FileSize", &scz); | 122 | hr = XmlGetAttributeEx(pixnNode, L"FileSize", &scz); |
125 | if (E_NOTFOUND != hr) | 123 | ExitOnOptionalXmlQueryFailure(hr, fXmlFound, "Failed to get @FileSize."); |
126 | { | ||
127 | ExitOnFailure(hr, "Failed to get @FileSize."); | ||
128 | 124 | ||
125 | if (fXmlFound) | ||
126 | { | ||
129 | hr = StrStringToUInt64(scz, 0, &pPayload->qwFileSize); | 127 | hr = StrStringToUInt64(scz, 0, &pPayload->qwFileSize); |
130 | ExitOnFailure(hr, "Failed to parse @FileSize."); | 128 | ExitOnFailure(hr, "Failed to parse @FileSize."); |
131 | 129 | ||
@@ -134,10 +132,10 @@ extern "C" HRESULT PayloadsParseFromXml( | |||
134 | 132 | ||
135 | // @CertificateAuthorityKeyIdentifier | 133 | // @CertificateAuthorityKeyIdentifier |
136 | hr = XmlGetAttributeEx(pixnNode, L"CertificateRootPublicKeyIdentifier", &scz); | 134 | hr = XmlGetAttributeEx(pixnNode, L"CertificateRootPublicKeyIdentifier", &scz); |
137 | if (E_NOTFOUND != hr) | 135 | ExitOnOptionalXmlQueryFailure(hr, fXmlFound, "Failed to get @CertificateRootPublicKeyIdentifier."); |
138 | { | ||
139 | ExitOnFailure(hr, "Failed to get @CertificateRootPublicKeyIdentifier."); | ||
140 | 136 | ||
137 | if (fXmlFound) | ||
138 | { | ||
141 | hr = StrAllocHexDecode(scz, &pPayload->pbCertificateRootPublicKeyIdentifier, &pPayload->cbCertificateRootPublicKeyIdentifier); | 139 | hr = StrAllocHexDecode(scz, &pPayload->pbCertificateRootPublicKeyIdentifier, &pPayload->cbCertificateRootPublicKeyIdentifier); |
142 | ExitOnFailure(hr, "Failed to hex decode @CertificateRootPublicKeyIdentifier."); | 140 | ExitOnFailure(hr, "Failed to hex decode @CertificateRootPublicKeyIdentifier."); |
143 | 141 | ||
@@ -146,20 +144,20 @@ extern "C" HRESULT PayloadsParseFromXml( | |||
146 | 144 | ||
147 | // @CertificateThumbprint | 145 | // @CertificateThumbprint |
148 | hr = XmlGetAttributeEx(pixnNode, L"CertificateRootThumbprint", &scz); | 146 | hr = XmlGetAttributeEx(pixnNode, L"CertificateRootThumbprint", &scz); |
149 | if (E_NOTFOUND != hr) | 147 | ExitOnOptionalXmlQueryFailure(hr, fXmlFound, "Failed to get @CertificateRootThumbprint."); |
150 | { | ||
151 | ExitOnFailure(hr, "Failed to get @CertificateRootThumbprint."); | ||
152 | 148 | ||
149 | if (fXmlFound) | ||
150 | { | ||
153 | hr = StrAllocHexDecode(scz, &pPayload->pbCertificateRootThumbprint, &pPayload->cbCertificateRootThumbprint); | 151 | hr = StrAllocHexDecode(scz, &pPayload->pbCertificateRootThumbprint, &pPayload->cbCertificateRootThumbprint); |
154 | ExitOnFailure(hr, "Failed to hex decode @CertificateRootThumbprint."); | 152 | ExitOnFailure(hr, "Failed to hex decode @CertificateRootThumbprint."); |
155 | } | 153 | } |
156 | 154 | ||
157 | // @Hash | 155 | // @Hash |
158 | hr = XmlGetAttributeEx(pixnNode, L"Hash", &scz); | 156 | hr = XmlGetAttributeEx(pixnNode, L"Hash", &scz); |
159 | if (E_NOTFOUND != hr) | 157 | ExitOnOptionalXmlQueryFailure(hr, fXmlFound, "Failed to get @Hash."); |
160 | { | ||
161 | ExitOnFailure(hr, "Failed to get @Hash."); | ||
162 | 158 | ||
159 | if (fXmlFound) | ||
160 | { | ||
163 | hr = StrAllocHexDecode(scz, &pPayload->pbHash, &pPayload->cbHash); | 161 | hr = StrAllocHexDecode(scz, &pPayload->pbHash, &pPayload->cbHash); |
164 | ExitOnFailure(hr, "Failed to hex decode the Payload/@Hash."); | 162 | ExitOnFailure(hr, "Failed to hex decode the Payload/@Hash."); |
165 | 163 | ||
@@ -171,11 +169,11 @@ extern "C" HRESULT PayloadsParseFromXml( | |||
171 | 169 | ||
172 | if (BURN_PAYLOAD_VERIFICATION_NONE == pPayload->verification) | 170 | if (BURN_PAYLOAD_VERIFICATION_NONE == pPayload->verification) |
173 | { | 171 | { |
174 | ExitOnRootFailure(hr = E_INVALIDDATA, "There was no verification information for payload: %ls", pPayload->sczKey); | 172 | ExitWithRootFailure(hr, E_INVALIDDATA, "There was no verification information for payload: %ls", pPayload->sczKey); |
175 | } | 173 | } |
176 | else if (BURN_PAYLOAD_VERIFICATION_HASH == pPayload->verification && !fValidFileSize) | 174 | else if (BURN_PAYLOAD_VERIFICATION_HASH == pPayload->verification && !fValidFileSize) |
177 | { | 175 | { |
178 | ExitOnRootFailure(hr = E_INVALIDDATA, "File size is required when verifying by hash for payload: %ls", pPayload->sczKey); | 176 | ExitWithRootFailure(hr, E_INVALIDDATA, "File size is required when verifying by hash for payload: %ls", pPayload->sczKey); |
179 | } | 177 | } |
180 | 178 | ||
181 | if (pPayload->fLayoutOnly) | 179 | if (pPayload->fLayoutOnly) |
@@ -321,8 +319,7 @@ extern "C" HRESULT PayloadExtractUXContainer( | |||
321 | // if the payload has not been acquired | 319 | // if the payload has not been acquired |
322 | if (BURN_PAYLOAD_STATE_ACQUIRED > pPayload->state) | 320 | if (BURN_PAYLOAD_STATE_ACQUIRED > pPayload->state) |
323 | { | 321 | { |
324 | hr = E_INVALIDDATA; | 322 | ExitWithRootFailure(hr, E_INVALIDDATA, "Payload was not found in container: %ls", pPayload->sczKey); |
325 | ExitOnRootFailure(hr, "Payload was not found in container: %ls", pPayload->sczKey); | ||
326 | } | 323 | } |
327 | } | 324 | } |
328 | 325 | ||