oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/tar/binaries/BinaryReferencesIndexLoaderV2.java [60:92]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    public static BinaryReferencesIndex parseBinaryReferencesIndex(Buffer buffer) throws InvalidBinaryReferencesIndexException {
        Buffer data = buffer.slice();
        data.limit(data.limit() - FOOTER_SIZE);

        buffer.position(buffer.limit() - FOOTER_SIZE);
        Buffer meta = buffer.slice();

        int crc32 = meta.getInt();
        int count = meta.getInt();
        int size = meta.getInt();
        int magic = meta.getInt();

        if (magic != MAGIC) {
            throw new InvalidBinaryReferencesIndexException("Invalid magic number");
        }
        if (count < 0) {
            throw new InvalidBinaryReferencesIndexException("Invalid count");
        }
        if (size < count * 22 + 16) {
            throw new InvalidBinaryReferencesIndexException("Invalid size");
        }

        CRC32 checksum = new CRC32();
        data.mark();
        data.update(checksum);
        data.reset();

        if ((int) (checksum.getValue()) != crc32) {
            throw new InvalidBinaryReferencesIndexException("Invalid checksum");
        }

        return new BinaryReferencesIndex(parseBinaryReferencesIndex(count, data));
    }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/tar/binaries/BinaryReferencesIndexLoaderV1.java [60:92]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    public static BinaryReferencesIndex parseBinaryReferencesIndex(Buffer buffer) throws InvalidBinaryReferencesIndexException {
        Buffer data = buffer.slice();
        data.limit(data.limit() - FOOTER_SIZE);

        buffer.position(buffer.limit() - FOOTER_SIZE);
        Buffer meta = buffer.slice();

        int crc32 = meta.getInt();
        int count = meta.getInt();
        int size = meta.getInt();
        int magic = meta.getInt();

        if (magic != MAGIC) {
            throw new InvalidBinaryReferencesIndexException("Invalid magic number");
        }
        if (count < 0) {
            throw new InvalidBinaryReferencesIndexException("Invalid count");
        }
        if (size < count * 22 + 16) {
            throw new InvalidBinaryReferencesIndexException("Invalid size");
        }

        CRC32 checksum = new CRC32();
        data.mark();
        data.update(checksum);
        data.reset();

        if ((int) (checksum.getValue()) != crc32) {
            throw new InvalidBinaryReferencesIndexException("Invalid checksum");
        }

        return new BinaryReferencesIndex(parseBinaryReferencesIndex(count, data));
    }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



