Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8278794

Infinite loop in DeflaterOutputStream.finish()

    XMLWordPrintable

    Details

      Backports

        Description

        Fix for https://bugs.openjdk.java.net/browse/JDK-8193682 has not handled infinite loop issue in DeflaterOutputStream.finish().

        Test case :

        import java.io.IOException;
        import java.io.OutputStream;
        import java.util.Random;
        import java.util.zip.ZipEntry;
        import java.util.zip.DeflaterOutputStream;

        public class GZipLoopTest {
        private static final int FINISH_NUM = 512;

        public static void main(String[] args) {
        test();
        }

        private static void test() {

        byte[] b = new byte[FINISH_NUM];
        Random rand = new Random();
        rand.nextBytes(b);
        DeflaterOutputStream zip = new DeflaterOutputStream(new OutputStream() {
        @Override
        public void write(byte[] b, int off, int len) throws IOException{
        throw new IOException();
        }
        @Override
        public void write(byte b[]) throws IOException {}
        @Override
        public void write(int b) throws IOException {}
        });
        try {
        zip.write(b , 0, 512);
        } catch (IOException ex) {
        ex.printStackTrace();
        }
        try {
        zip.finish();
        } catch (IOException ex) {
        ex.printStackTrace();
        }

        for(int i=0;i<3;i++) {
        try {
        zip.write(b , 0, 512);
        } catch (IOException ex) {
        ex.printStackTrace();
        }
        }

        }

        }




          Attachments

            Issue Links

              Activity

                People

                Assignee:
                rreddy Ravi Reddy
                Reporter:
                rreddy Ravi Reddy
                Votes:
                0 Vote for this issue
                Watchers:
                8 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: