Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2202,9 +2202,10 @@ private void sanityCheckSubStreamsInfo(final ByteBuffer header, final ArchiveSta
} else {
int folderIdx = 0;
for (final int numUnpackSubStreams : numUnpackSubStreamsPerFolder) {
if (numUnpackSubStreams != 1 || stats.folderHasCrc == null || !stats.folderHasCrc.get(folderIdx++)) {
if (numUnpackSubStreams != 1 || stats.folderHasCrc == null || !stats.folderHasCrc.get(folderIdx)) {
numDigests = accumulate(numDigests, numUnpackSubStreams, "numDigests");
}
folderIdx++;
}
}
if (nid == NID.kCRC) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1260,4 +1260,22 @@ void testSignatureCheck() {
final byte[] data3 = { '7', 'z', (byte) 0xBC, (byte) 0xAF, 0x27, 0x1D };
assertFalse(SevenZFile.matches(data3, data3.length));
}

/**
* Tests an archive whose folders are, in this order, one entry with a folder CRC, two entries without, and one entry with a folder CRC.
*/
@Test
void testMixedFolderCrcs() throws Exception {
try (SevenZFile sevenZFile = getSevenZFile("COMPRESS-737.7z")) {
final List<String> names = new ArrayList<>();
final List<String> contents = new ArrayList<>();
SevenZArchiveEntry entry;
while ((entry = sevenZFile.getNextEntry()) != null) {
names.add(entry.getName());
contents.add(new String(IOUtils.toByteArray(sevenZFile.getInputStream(entry)), UTF_8));
}
assertEquals(Arrays.asList("aaa", "ccc", "ddd", "bbb"), names);
assertEquals(names, contents);
}
}
}
Binary file added src/test/resources/COMPRESS-737.7z
Binary file not shown.