@Override
	public byte[] readBytes(long index, long length) throws IOException {
		if (index < 0 || (index + length - 1) > Integer.MAX_VALUE) {
			throw new IOException("index/length of range");
		}
		int ilen = (int) length;
		byte[] bytes = new byte[ilen];
		if (buffer.getBytes(bytes, (int) index) != ilen) {
			throw new RuntimeException("index/length of range");
		}
		return bytes;
	}
Return maximum length since actual length is unknown

@return maximum possible length
Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/dump/cmd/ProgramInsertByteProvider.java