@Override public Decompressor createDecompressor() { return (ZlibFactory.isNativeZlibLoaded(conf)) ? new GzipZlibDecompressor() : new BuiltInGzipDecompressor(); }
checkAndCopyBytesToLocal(n); // modifies userBufLen, etc. if (localBufOff >= 10) { // should be strictly == processBasicHeader(); // sig, compression method, flagbits localBufOff = 0; // no further need for basic header state = GzipStateLabel.HEADER_EXTRA_FIELD; checkAndCopyBytesToLocal(n); if (localBufOff >= 2) { numExtraFieldBytesRemaining = readUShortLE(localBuf, 0); localBufOff = 0; checkAndSkipBytes(n); // modifies userBufLen, etc. numExtraFieldBytesRemaining -= n; boolean doneWithFilename = checkAndSkipBytesUntilNull(); if (!doneWithFilename) { return; // exit early: used up entire buffer without hitting NULL boolean doneWithComment = checkAndSkipBytesUntilNull(); if (!doneWithComment) { return; // exit early: used up entire buffer assert (localBufOff < 2); int n = Math.min(userBufLen, 2-localBufOff); copyBytesToLocal(n); if (localBufOff >= 2) { long headerCRC = readUShortLE(localBuf, 0); if (headerCRC != (crc.getValue() & 0xffff)) { throw new IOException("gzip header CRC failure");
if (readUShortLE(localBuf, 0) != GZIP_MAGIC_ID) { throw new IOException("not a gzip file"); if (readUByte(localBuf, 2) != GZIP_DEFLATE_METHOD) { throw new IOException("gzip data not compressed with deflate method"); int flg = readUByte(localBuf, 3); if ((flg & GZIP_FLAGBITS_RESERVED) != 0) { throw new IOException("unknown gzip format (reserved flagbits set)");
copyBytesToLocal(n); if (localBufOff >= 4) { long streamCRC = readUIntLE(localBuf, 0); if (streamCRC != crc.getValue()) { throw new IOException("gzip stream CRC failure"); assert (localBufOff < 4); // initially 0, but may need multiple calls int n = Math.min(userBufLen, 4-localBufOff); copyBytesToLocal(n); // modifies userBufLen, etc. if (localBufOff >= 4) { // should be strictly == long inputSize = readUIntLE(localBuf, 0); if (inputSize != (inflater.getBytesWritten() & 0xffffffffL)) { throw new IOException(
@Test public void testBuiltInGzipDecompressorExceptions() { BuiltInGzipDecompressor decompresser = new BuiltInGzipDecompressor(); try { decompresser.setInput(null, 0, 1); } catch (NullPointerException ex) { decompresser.setInput(new byte[] { 0 }, 0, -1); } catch (ArrayIndexOutOfBoundsException ex) { decompresser.getBytesRead() == 0); assertTrue("decompresser.getRemaining error", decompresser.getRemaining() == 0); decompresser.reset(); decompresser.end(); Decompressor decompressor = new BuiltInGzipDecompressor(); DataInputBuffer gzbuf = new DataInputBuffer(); decompStream = new DecompressorStream(gzbuf, decompressor); int buffSize = 1 * 1024; byte buffer[] = new byte[buffSize]; Decompressor decompressor = new BuiltInGzipDecompressor(); DataInputBuffer gzbuf = new DataInputBuffer(); decompStream = new DecompressorStream(gzbuf, decompressor); int buffSize = 1 * 1024; byte buffer[] = new byte[buffSize]; Decompressor decompressor = new BuiltInGzipDecompressor(); DataInputBuffer gzbuf = new DataInputBuffer();
@Test public void testBuiltInGzipDecompressorExceptions() { BuiltInGzipDecompressor decompresser = new BuiltInGzipDecompressor(); try { decompresser.setInput(null, 0, 1); } catch (NullPointerException ex) { decompresser.setInput(new byte[] { 0 }, 0, -1); } catch (ArrayIndexOutOfBoundsException ex) { decompresser.getBytesRead() == 0); assertTrue("decompresser.getRemaining error", decompresser.getRemaining() == 0); decompresser.reset(); decompresser.end(); Decompressor decompressor = new BuiltInGzipDecompressor(); DataInputBuffer gzbuf = new DataInputBuffer(); decompStream = new DecompressorStream(gzbuf, decompressor); int buffSize = 1 * 1024; byte buffer[] = new byte[buffSize]; Decompressor decompressor = new BuiltInGzipDecompressor(); DataInputBuffer gzbuf = new DataInputBuffer(); decompStream = new DecompressorStream(gzbuf, decompressor); int buffSize = 1 * 1024; byte buffer[] = new byte[buffSize]; Decompressor decompressor = new BuiltInGzipDecompressor(); DataInputBuffer gzbuf = new DataInputBuffer();
if (readUShortLE(localBuf, 0) != GZIP_MAGIC_ID) { throw new IOException("not a gzip file"); if (readUByte(localBuf, 2) != GZIP_DEFLATE_METHOD) { throw new IOException("gzip data not compressed with deflate method"); int flg = readUByte(localBuf, 3); if ((flg & GZIP_FLAGBITS_RESERVED) != 0) { throw new IOException("unknown gzip format (reserved flagbits set)");
copyBytesToLocal(n); if (localBufOff >= 4) { long streamCRC = readUIntLE(localBuf, 0); if (streamCRC != crc.getValue()) { throw new IOException("gzip stream CRC failure"); assert (localBufOff < 4); // initially 0, but may need multiple calls int n = Math.min(userBufLen, 4-localBufOff); copyBytesToLocal(n); // modifies userBufLen, etc. if (localBufOff >= 4) { // should be strictly == long inputSize = readUIntLE(localBuf, 0); if (inputSize != (inflater.getBytesWritten() & 0xffffffffL)) { throw new IOException(
checkAndCopyBytesToLocal(n); // modifies userBufLen, etc. if (localBufOff >= 10) { // should be strictly == processBasicHeader(); // sig, compression method, flagbits localBufOff = 0; // no further need for basic header state = GzipStateLabel.HEADER_EXTRA_FIELD; checkAndCopyBytesToLocal(n); if (localBufOff >= 2) { numExtraFieldBytesRemaining = readUShortLE(localBuf, 0); localBufOff = 0; checkAndSkipBytes(n); // modifies userBufLen, etc. numExtraFieldBytesRemaining -= n; boolean doneWithFilename = checkAndSkipBytesUntilNull(); if (!doneWithFilename) { return; // exit early: used up entire buffer without hitting NULL boolean doneWithComment = checkAndSkipBytesUntilNull(); if (!doneWithComment) { return; // exit early: used up entire buffer assert (localBufOff < 2); int n = Math.min(userBufLen, 2-localBufOff); copyBytesToLocal(n); if (localBufOff >= 2) { long headerCRC = readUShortLE(localBuf, 0); if (headerCRC != (crc.getValue() & 0xffff)) { throw new IOException("gzip header CRC failure");
if (readUShortLE(localBuf, 0) != GZIP_MAGIC_ID) { throw new IOException("not a gzip file"); if (readUByte(localBuf, 2) != GZIP_DEFLATE_METHOD) { throw new IOException("gzip data not compressed with deflate method"); int flg = readUByte(localBuf, 3); if ((flg & GZIP_FLAGBITS_RESERVED) != 0) { throw new IOException("unknown gzip format (reserved flagbits set)");
copyBytesToLocal(n); if (localBufOff >= 4) { long streamCRC = readUIntLE(localBuf, 0); if (streamCRC != crc.getValue()) { throw new IOException("gzip stream CRC failure"); assert (localBufOff < 4); // initially 0, but may need multiple calls int n = Math.min(userBufLen, 4-localBufOff); copyBytesToLocal(n); // modifies userBufLen, etc. if (localBufOff >= 4) { // should be strictly == long inputSize = readUIntLE(localBuf, 0); if (inputSize != (inflater.getBytesWritten() & 0xffffffffL)) { throw new IOException(
@Override public Decompressor createDecompressor() { return (ZlibFactory.isNativeZlibLoaded(conf)) ? new GzipZlibDecompressor() : new BuiltInGzipDecompressor(); }
checkAndCopyBytesToLocal(n); // modifies userBufLen, etc. if (localBufOff >= 10) { // should be strictly == processBasicHeader(); // sig, compression method, flagbits localBufOff = 0; // no further need for basic header state = GzipStateLabel.HEADER_EXTRA_FIELD; checkAndCopyBytesToLocal(n); if (localBufOff >= 2) { numExtraFieldBytesRemaining = readUShortLE(localBuf, 0); localBufOff = 0; checkAndSkipBytes(n); // modifies userBufLen, etc. numExtraFieldBytesRemaining -= n; boolean doneWithFilename = checkAndSkipBytesUntilNull(); if (!doneWithFilename) { return; // exit early: used up entire buffer without hitting NULL boolean doneWithComment = checkAndSkipBytesUntilNull(); if (!doneWithComment) { return; // exit early: used up entire buffer assert (localBufOff < 2); int n = Math.min(userBufLen, 2-localBufOff); copyBytesToLocal(n); if (localBufOff >= 2) { long headerCRC = readUShortLE(localBuf, 0); if (headerCRC != (crc.getValue() & 0xffff)) { throw new IOException("gzip header CRC failure");
if (readUShortLE(localBuf, 0) != GZIP_MAGIC_ID) { throw new IOException("not a gzip file"); if (readUByte(localBuf, 2) != GZIP_DEFLATE_METHOD) { throw new IOException("gzip data not compressed with deflate method"); int flg = readUByte(localBuf, 3); if ((flg & GZIP_FLAGBITS_RESERVED) != 0) { throw new IOException("unknown gzip format (reserved flagbits set)");
copyBytesToLocal(n); if (localBufOff >= 4) { long streamCRC = readUIntLE(localBuf, 0); if (streamCRC != crc.getValue()) { throw new IOException("gzip stream CRC failure"); assert (localBufOff < 4); // initially 0, but may need multiple calls int n = Math.min(userBufLen, 4-localBufOff); copyBytesToLocal(n); // modifies userBufLen, etc. if (localBufOff >= 4) { // should be strictly == long inputSize = readUIntLE(localBuf, 0); if (inputSize != (inflater.getBytesWritten() & 0xffffffffL)) { throw new IOException(
@Override public Decompressor createDecompressor() { return (ZlibFactory.isNativeZlibLoaded(conf)) ? new GzipZlibDecompressor() : new BuiltInGzipDecompressor(); }
checkAndCopyBytesToLocal(n); // modifies userBufLen, etc. if (localBufOff >= 10) { // should be strictly == processBasicHeader(); // sig, compression method, flagbits localBufOff = 0; // no further need for basic header state = GzipStateLabel.HEADER_EXTRA_FIELD; checkAndCopyBytesToLocal(n); if (localBufOff >= 2) { numExtraFieldBytesRemaining = readUShortLE(localBuf, 0); localBufOff = 0; checkAndSkipBytes(n); // modifies userBufLen, etc. numExtraFieldBytesRemaining -= n; boolean doneWithFilename = checkAndSkipBytesUntilNull(); if (!doneWithFilename) { return; // exit early: used up entire buffer without hitting NULL boolean doneWithComment = checkAndSkipBytesUntilNull(); if (!doneWithComment) { return; // exit early: used up entire buffer assert (localBufOff < 2); int n = Math.min(userBufLen, 2-localBufOff); copyBytesToLocal(n); if (localBufOff >= 2) { long headerCRC = readUShortLE(localBuf, 0); if (headerCRC != (crc.getValue() & 0xffff)) { throw new IOException("gzip header CRC failure");