aboutsummaryrefslogtreecommitdiff
path: root/src/burn
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2021-11-02 17:47:46 -0500
committerSean Hall <r.sean.hall@gmail.com>2021-11-03 10:53:41 -0500
commit323f62d3d0f4b73db5fde8977e2540194c6de006 (patch)
treeefcbb140502f5c274052bcc1ef86e202e8bf6a7b /src/burn
parentce3aea757a01f0eea906fa610501a66735ef3a15 (diff)
downloadwix-323f62d3d0f4b73db5fde8977e2540194c6de006.tar.gz
wix-323f62d3d0f4b73db5fde8977e2540194c6de006.tar.bz2
wix-323f62d3d0f4b73db5fde8977e2540194c6de006.zip
Follow up for multiple attached container support
* validate cContainers * use previous embeddedid format and use intermediate folder when extracting attached containers * remove special cases for 0 byte containers in BurnCommon classes and Insignia * don't hardcode max containers * reduce properties in BurnCommon * add e2e test #6144
Diffstat (limited to 'src/burn')
-rw-r--r--src/burn/engine/section.cpp24
-rw-r--r--src/burn/stub/StubSection.cpp3
2 files changed, 15 insertions, 12 deletions
diff --git a/src/burn/engine/section.cpp b/src/burn/engine/section.cpp
index 1fd6cce4..a9c7927e 100644
--- a/src/burn/engine/section.cpp
+++ b/src/burn/engine/section.cpp
@@ -26,7 +26,7 @@ typedef struct _BURN_SECTION_HEADER
26 26
27 DWORD dwFormat; 27 DWORD dwFormat;
28 DWORD cContainers; 28 DWORD cContainers;
29 DWORD rgcbContainers[116]; 29 DWORD rgcbContainers[1];
30} BURN_SECTION_HEADER; 30} BURN_SECTION_HEADER;
31 31
32static HRESULT VerifySectionMatchesMemoryPEHeader( 32static HRESULT VerifySectionMatchesMemoryPEHeader(
@@ -53,6 +53,7 @@ extern "C" HRESULT SectionInitialize(
53 IMAGE_SECTION_HEADER sectionHeader = { }; 53 IMAGE_SECTION_HEADER sectionHeader = { };
54 DWORD_PTR dwOriginalChecksumAndSignatureOffset = 0; 54 DWORD_PTR dwOriginalChecksumAndSignatureOffset = 0;
55 BURN_SECTION_HEADER* pBurnSectionHeader = NULL; 55 BURN_SECTION_HEADER* pBurnSectionHeader = NULL;
56 DWORD cMaxContainers = 0;
56 57
57 pSection->hEngineFile = hEngineFile; 58 pSection->hEngineFile = hEngineFile;
58 ExitOnInvalidHandleWithLastError(pSection->hEngineFile, hr, "Failed to open handle to engine process path."); 59 ExitOnInvalidHandleWithLastError(pSection->hEngineFile, hr, "Failed to open handle to engine process path.");
@@ -142,8 +143,7 @@ extern "C" HRESULT SectionInitialize(
142 } 143 }
143 if (sizeof(IMAGE_SECTION_HEADER) > cbRead) 144 if (sizeof(IMAGE_SECTION_HEADER) > cbRead)
144 { 145 {
145 hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA); 146 ExitWithRootFailure(hr, E_INVALIDDATA, "Failed to read complete image section header, index: %u", i);
146 ExitOnRootFailure(hr, "Failed to read complete image section header, index: %u", i);
147 } 147 }
148 148
149 // compare header name 149 // compare header name
@@ -156,8 +156,7 @@ extern "C" HRESULT SectionInitialize(
156 // fail if we hit the end 156 // fail if we hit the end
157 if (i + 1 >= ntHeader.FileHeader.NumberOfSections) 157 if (i + 1 >= ntHeader.FileHeader.NumberOfSections)
158 { 158 {
159 hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA); 159 ExitWithRootFailure(hr, E_INVALIDDATA, "Failed to find Burn section.");
160 ExitOnRootFailure(hr, "Failed to find Burn section.");
161 } 160 }
162 } 161 }
163 162
@@ -168,8 +167,7 @@ extern "C" HRESULT SectionInitialize(
168 // check size of section 167 // check size of section
169 if (sizeof(BURN_SECTION_HEADER) > sectionHeader.SizeOfRawData) 168 if (sizeof(BURN_SECTION_HEADER) > sectionHeader.SizeOfRawData)
170 { 169 {
171 hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA); 170 ExitWithRootFailure(hr, E_INVALIDDATA, "Failed to read section info, data too short: %u", sectionHeader.SizeOfRawData);
172 ExitOnRootFailure(hr, "Failed to read section info, data to short: %u", sectionHeader.SizeOfRawData);
173 } 171 }
174 172
175 // allocate buffer for section info 173 // allocate buffer for section info
@@ -193,15 +191,19 @@ extern "C" HRESULT SectionInitialize(
193 } 191 }
194 else if (sectionHeader.SizeOfRawData > cbRead) 192 else if (sectionHeader.SizeOfRawData > cbRead)
195 { 193 {
196 hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA); 194 ExitWithRootFailure(hr, E_INVALIDDATA, "Failed to read complete section info.");
197 ExitOnRootFailure(hr, "Failed to read complete section info.");
198 } 195 }
199 196
200 // validate version of section info 197 // validate version of section info
201 if (BURN_SECTION_VERSION != pBurnSectionHeader->dwVersion) 198 if (BURN_SECTION_VERSION != pBurnSectionHeader->dwVersion)
202 { 199 {
203 hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA); 200 ExitWithRootFailure(hr, E_INVALIDDATA, "Failed to read section info, unsupported version: %08x", pBurnSectionHeader->dwVersion);
204 ExitOnRootFailure(hr, "Failed to read section info, unsupported version: %08x", pBurnSectionHeader->dwVersion); 201 }
202
203 cMaxContainers = (sectionHeader.SizeOfRawData - offsetof(BURN_SECTION_HEADER, rgcbContainers)) / sizeof(DWORD);
204 if (cMaxContainers < pBurnSectionHeader->cContainers)
205 {
206 ExitWithRootFailure(hr, E_INVALIDDATA, "Invalid section info, cContainers too large: %u", pBurnSectionHeader->cContainers);
205 } 207 }
206 208
207 hr = FileSizeByHandle(pSection->hSourceEngineFile, &llSize); 209 hr = FileSizeByHandle(pSection->hSourceEngineFile, &llSize);
diff --git a/src/burn/stub/StubSection.cpp b/src/burn/stub/StubSection.cpp
index 01b4b576..2191a138 100644
--- a/src/burn/stub/StubSection.cpp
+++ b/src/burn/stub/StubSection.cpp
@@ -18,5 +18,6 @@ static DWORD dwOriginalSignatureSize = 0;
18 18
19static DWORD dwContainerFormat = 1; 19static DWORD dwContainerFormat = 1;
20static DWORD dwContainerCount = 0; 20static DWORD dwContainerCount = 0;
21static DWORD qwAttachedContainerSizes[116]; // Including UX container 21// (512 (minimum section size) - 48 (size of above data)) / 4 (size of DWORD)
22static DWORD qwAttachedContainerSizes[116];
22#pragma data_seg(pop) 23#pragma data_seg(pop)