Mercurial > jhg
diff src/com/tmate/hgkit/fs/DataAccessProvider.java @ 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 | 382cfe9463db |
children | 71a9ba42cee8 |
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); } }