Mercurial > hg4j
changeset 23:6f9aca1a97be
Severe defect in buffer wrap on seek
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Thu, 06 Jan 2011 03:30:43 +0100 |
parents | 603806cd2dc6 |
children | d4fdd1845b3f |
files | src/com/tmate/hgkit/fs/DataAccessProvider.java |
diffstat | 1 files changed, 5 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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); } }