public static void verify(boolean condition, long offset, String reason) { if (!condition) { throw new MalformedInputException(offset, reason); } }
public static MalformedInputException fail(long offset, String reason) { throw new MalformedInputException(offset, reason); } }
public static void verify(boolean condition, long offset, String reason) { if (!condition) { throw new MalformedInputException(offset, reason); } }
public static MalformedInputException fail(long offset, String reason) { throw new MalformedInputException(offset, reason); } }
private static int getUnsignedByteSafe(Object base, long address, long limit) { if (address >= limit) { throw new MalformedInputException(limit - address, "Input is truncated"); } return UNSAFE.getByte(base, address) & 0xFF; } }
private static int getUnsignedByteSafe(Object base, long address, long limit) { if (address >= limit) { throw new MalformedInputException(limit - address, "Input is truncated"); } return UNSAFE.getByte(base, address) & 0xFF; } }
private static int verifyMagic(Object inputBase, long inputAddress, long inputLimit) { verify(inputLimit - inputAddress >= 4, inputAddress, "Not enough input bytes"); int magic = UNSAFE.getInt(inputBase, inputAddress); if (magic != MAGIC_NUMBER) { if (magic == V07_MAGIC_NUMBER) { throw new MalformedInputException(inputAddress, "Data encoded in unsupported ZSTD v0.7 format"); } throw new MalformedInputException(inputAddress, "Invalid magic prefix: " + Integer.toHexString(magic)); } return SIZE_OF_INT; } }
private static int verifyMagic(Object inputBase, long inputAddress, long inputLimit) { verify(inputLimit - inputAddress >= 4, inputAddress, "Not enough input bytes"); int magic = UNSAFE.getInt(inputBase, inputAddress); if (magic != MAGIC_NUMBER) { if (magic == V07_MAGIC_NUMBER) { throw new MalformedInputException(inputAddress, "Data encoded in unsupported ZSTD v0.7 format"); } throw new MalformedInputException(inputAddress, "Invalid magic prefix: " + Integer.toHexString(magic)); } return SIZE_OF_INT; } }
throw new MalformedInputException(input - inputAddress); throw new MalformedInputException(input - inputAddress); if (literalOutputLimit > fastOutputLimit || input + literalLength > inputLimit - SIZE_OF_LONG) { if (literalOutputLimit > outputLimit) { throw new MalformedInputException(input - inputAddress); throw new MalformedInputException(input - inputAddress); throw new MalformedInputException(input - inputAddress);
throw new MalformedInputException(0, "input is empty"); throw new MalformedInputException(input - inputAddress, "attempt to write last literal outside of destination buffer"); throw new MalformedInputException(input - inputAddress, "all input must be consumed"); throw new MalformedInputException(input - inputAddress, "offset outside destination buffer"); do { if (input > inputLimit - LAST_LITERAL_SIZE) { throw new MalformedInputException(input - inputAddress); throw new MalformedInputException(input - inputAddress, String.format("last %s bytes must be literals", LAST_LITERAL_SIZE));
throw new MalformedInputException(0, "input is empty"); throw new MalformedInputException(input - inputAddress, "attempt to write last literal outside of destination buffer"); throw new MalformedInputException(input - inputAddress, "all input must be consumed"); throw new MalformedInputException(input - inputAddress, "offset outside destination buffer"); do { if (input > inputLimit - LAST_LITERAL_SIZE) { throw new MalformedInputException(input - inputAddress); throw new MalformedInputException(input - inputAddress, String.format("last %s bytes must be literals", LAST_LITERAL_SIZE));
throw new MalformedInputException(input - inputAddress); throw new MalformedInputException(input - inputAddress); if (literalOutputLimit > fastOutputLimit || input + literalLength > inputLimit - SIZE_OF_LONG) { if (literalOutputLimit > outputLimit) { throw new MalformedInputException(input - inputAddress); throw new MalformedInputException(input - inputAddress); throw new MalformedInputException(input - inputAddress);
public static int decompress( final Object inputBase, final long inputAddress, final long inputLimit, final Object outputBase, final long outputAddress, final long outputLimit) { // Read the uncompressed length from the front of the input long input = inputAddress; int[] varInt = readUncompressedLength(inputBase, input, inputLimit); int expectedLength = varInt[0]; input += varInt[1]; SnappyInternalUtils.checkArgument(expectedLength <= (outputLimit - outputAddress), "Uncompressed length %s must be less than %s", expectedLength, (outputLimit - outputAddress)); // Process the entire input int uncompressedSize = uncompressAll( inputBase, input, inputLimit, outputBase, outputAddress, outputLimit); if (!(expectedLength == uncompressedSize)) { throw new MalformedInputException(0, String.format("Recorded length is %s bytes but actual length after decompression is %s bytes ", expectedLength, uncompressedSize)); } return expectedLength; }
public static int decompress( final Object inputBase, final long inputAddress, final long inputLimit, final Object outputBase, final long outputAddress, final long outputLimit) { // Read the uncompressed length from the front of the input long input = inputAddress; int[] varInt = readUncompressedLength(inputBase, input, inputLimit); int expectedLength = varInt[0]; input += varInt[1]; SnappyInternalUtils.checkArgument(expectedLength <= (outputLimit - outputAddress), "Uncompressed length %s must be less than %s", expectedLength, (outputLimit - outputAddress)); // Process the entire input int uncompressedSize = uncompressAll( inputBase, input, inputLimit, outputBase, outputAddress, outputLimit); if (!(expectedLength == uncompressedSize)) { throw new MalformedInputException(0, String.format("Recorded length is %s bytes but actual length after decompression is %s bytes ", expectedLength, uncompressedSize)); } return expectedLength; }
result |= (b & 0x7f) << 28; if ((b & 0x80) != 0) { throw new MalformedInputException(compressedAddress + bytesRead, "last byte of compressed length int has high bit set");
result |= (b & 0x7f) << 28; if ((b & 0x80) != 0) { throw new MalformedInputException(compressedAddress + bytesRead, "last byte of compressed length int has high bit set");