# HG changeset patch # User Artem Tikhomirov # Date 1294281043 -3600 # Node ID 6f9aca1a97bee6444b90420e26b820a5efd1988a # Parent 603806cd2dc6a3e833397dc34f70925a814dd9be Severe defect in buffer wrap on seek diff -r 603806cd2dc6 -r 6f9aca1a97be src/com/tmate/hgkit/fs/DataAccessProvider.java --- a/src/com/tmate/hgkit/fs/DataAccessProvider.java Thu Jan 06 03:30:20 2011 +0100 +++ b/src/com/tmate/hgkit/fs/DataAccessProvider.java Thu Jan 06 03:30:43 2011 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010 Artem Tikhomirov + * Copyright (c) 2010, 2011 Artem Tikhomirov */ package com.tmate.hgkit.fs; @@ -110,6 +110,9 @@ @Override public void seek(long offset) throws IOException { + if (offset > size) { + throw new IllegalArgumentException(); + } if (offset < bufferStartInFile + buffer.limit() && offset >= bufferStartInFile) { buffer.position((int) (offset - bufferStartInFile)); } else { @@ -130,7 +133,7 @@ buffer.position(newPos); } else { // - seek(fileChannel.position()+ bytes); + seek(bufferStartInFile + newPos); } }