This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug java/14446] New: GZIPInputStream: corrupted gzip file - crc mismatch


Using the GZIPInputStream I found out, that "sometimes" but not always the
following exception gets thrown (I've attached a file that causes the error):

java.util.zip.ZipException: corrupted gzip file - crc mismatch

So, you might use GZIPOutputStream to compress and then while
decompressing the error gets thrown.

I'm going to attach a small jar, that you might use to test.

java -jar zipper.jar compress test-document test-compressed
java -jar zipper.jar uncompress test-compressed test-uncompressed

Java version works without any problems...

gcj --main=com.condor_edv.e3m.util.compress.fun -o zipper zipper.jar

zipper compress test-document test-compressed
zipper uncompress test-compressed test-uncompressed

throws the error...

The source for the zipper.jar is compiled through nice (nice.sf.net)
but it only contains the following:

class CompressTest {

    public void deflate(InputStream in, OutputStream out) 
    {
	byte[] ba = new byte[buffersize];
        int b, count = 0;
	GZIPOutputStream gout = new GZIPOutputStream(out);
        try {
            while (true) {
                b = in.read();
                if (b == -1) throw new EOFException();
		ba[count++] = byte(b);
		if (count == buffersize) {
		    count = 0;
		    gout.write(ba, 0, buffersize);
		}
            }
        } catch (EOFException eof) {
        }
	gout.write(ba, 0, count);
	gout.finish();
    }

    public void inflate(InputStream in, OutputStream out) 
    {
	byte[] ba = new byte[buffersize];
        int b, count = 0;
	GZIPInputStream gin = new GZIPInputStream(in);
        try {
            while (true) {
                b = gin.read();
                if (b == -1) throw new EOFException();
		ba[count++] = byte(b);
		if (count == buffersize) {
		    count = 0;
		    out.write(ba, 0, buffersize);
		}
            }
        } catch (EOFException eof) {
        }
	out.write(ba, 0, count);
	out.flush();
    }
}

void main(String[] args) 
{
    try {
	if (args.length == 3) {
	    CompressTest c = new CompressTest();
	    // ok, let us convert some files
	    // (load|save) in out
	    FileInputStream in = new FileInputStream(args[1]);
	    FileOutputStream out = new FileOutputStream(args[2]);
	    if (args[0].equals("compress")) {
		c.deflate(in, out);
	    } else if (args[0].equals("uncompress")) {
		c.inflate(in, out);
	    } else System.out.println("Unknown Action: "+args[0]);
	    in.close();
	    out.close();
	} else {
	    System.out.println("Unsupported Action!");
	}
    } catch (Exception e) {
	e.printStackTrace();
    }
}

Hopefully someone can reproduce the bug...

Kind regards,
Christian

-- 
           Summary: GZIPInputStream: corrupted gzip file - crc mismatch
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: java
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: gcj at stuellenberg dot de
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i586-pc-linux-gnu
  GCC host triplet: i586-pc-linux-gnu
GCC target triplet: i586-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14446


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]