Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix COMPRESS-592
fix COMPRESS-592 by using LinkedHashMap
  • Loading branch information
PeterAlfredLee committed Oct 29, 2021
1 parent e8f94d0 commit 4246b88
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/changes/changes.xml
Expand Up @@ -489,6 +489,11 @@ you relied on the recovery attempt.">
files containing LZMA streams with end marker.
Github Pull Request #223.
</action>
<action issue="COMPRESS-592" type="fix" date="2021-10-29"
dev="Peter Lee" due-to="Roland Kreuzer">
Use LinkedHashMap for fileMap in SevenZFile.readFilesInfo,
as it will be read in specific order.
</action>
</release>
<release version="1.20" date="2020-02-08"
description="Release 1.20 (Java 7)">
Expand Down
Expand Up @@ -38,6 +38,7 @@
import java.util.BitSet;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -1367,7 +1368,7 @@ private void sanityCheckFilesInfo(final ByteBuffer header, final ArchiveStatisti

private void readFilesInfo(final ByteBuffer header, final Archive archive) throws IOException {
final int numFilesInt = (int) readUint64(header);
final Map<Integer, SevenZArchiveEntry> fileMap = new HashMap<>();
final Map<Integer, SevenZArchiveEntry> fileMap = new LinkedHashMap<>();
BitSet isEmptyStream = null;
BitSet isEmptyFile = null;
BitSet isAnti = null;
Expand Down
Expand Up @@ -766,7 +766,22 @@ public void testSevenZWithEOS() throws IOException {
}
}

private void test7zUnarchive(final File f, final SevenZMethod m, final byte[] password) throws Exception {
@Test
public void readBigSevenZipFile() throws IOException {
try (SevenZFile sevenZFile = new SevenZFile(getFile("COMPRESS-592.7z"))) {
SevenZArchiveEntry entry = sevenZFile.getNextEntry();
while (entry != null) {
if (entry.hasStream()) {
byte[] content = new byte[(int) entry.getSize()];
sevenZFile.read(content);
}
entry = sevenZFile.getNextEntry();
}
}
}


private void test7zUnarchive(final File f, final SevenZMethod m, final byte[] password) throws Exception {
try (SevenZFile sevenZFile = new SevenZFile(f, password)) {
test7zUnarchive(sevenZFile, m);
}
Expand Down
Binary file added src/test/resources/COMPRESS-592.7z
Binary file not shown.

0 comments on commit 4246b88

Please sign in to comment.