This is an automated email from the ASF dual-hosted git repository.

bodewig pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git

commit 3fe6b42110dc56d0d6fe0aaf80cfecb8feea5321
Author: Stefan Bodewig <bode...@apache.org>
AuthorDate: Sun Jun 6 08:09:38 2021 +0200

    make sure coders are only used once in folder
---
 .../java/org/apache/commons/compress/archivers/sevenz/Folder.java   | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git 
a/src/main/java/org/apache/commons/compress/archivers/sevenz/Folder.java 
b/src/main/java/org/apache/commons/compress/archivers/sevenz/Folder.java
index 1725be0..82fe51f 100644
--- a/src/main/java/org/apache/commons/compress/archivers/sevenz/Folder.java
+++ b/src/main/java/org/apache/commons/compress/archivers/sevenz/Folder.java
@@ -17,6 +17,7 @@
  */
 package org.apache.commons.compress.archivers.sevenz;
 
+import java.io.IOException;
 import java.util.Collections;
 import java.util.LinkedList;
 
@@ -53,13 +54,16 @@ class Folder {
      * only support single input stream decoders), the second reads
      * from the output of the first and so on.</p>
      */
-    Iterable<Coder> getOrderedCoders() {
+    Iterable<Coder> getOrderedCoders() throws IOException {
         if (packedStreams == null || coders == null || packedStreams.length == 
0 || coders.length == 0) {
             return Collections.emptyList();
         }
         final LinkedList<Coder> l = new LinkedList<>();
         int current = (int) packedStreams[0]; // more that 2^31 coders?
         while (current >= 0 && current < coders.length) {
+            if (l.contains(coders[current])) {
+                throw new IOException("folder uses the same coder more than 
once in coder chain");
+            }
             l.addLast(coders[current]);
             final int pair = findBindPairForOutStream(current);
             current = pair != -1 ? (int) bindPairs[pair].inIndex : -1;

Reply via email to