aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/poi/hssf/dev/BiffViewer.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/org/apache/poi/hssf/dev/BiffViewer.java')
-rw-r--r--src/java/org/apache/poi/hssf/dev/BiffViewer.java12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/java/org/apache/poi/hssf/dev/BiffViewer.java b/src/java/org/apache/poi/hssf/dev/BiffViewer.java
index cb17d84b56..631be8fd2d 100644
--- a/src/java/org/apache/poi/hssf/dev/BiffViewer.java
+++ b/src/java/org/apache/poi/hssf/dev/BiffViewer.java
@@ -527,20 +527,16 @@ public final class BiffViewer {
}
@Override
public int read(byte[] b, int off, int len) throws IOException {
+ if (b == null || off < 0 || len < 0 || b.length < off+len) {
+ throw new IllegalArgumentException();
+ }
if (_currentPos >= _currentSize) {
fillNextBuffer();
}
if (_currentPos >= _currentSize) {
return -1;
}
- int availSize = _currentSize - _currentPos;
- int result;
- if (len > availSize) {
- System.err.println("Unexpected request to read past end of current biff record");
- result = availSize;
- } else {
- result = len;
- }
+ final int result = Math.min(len, _currentSize - _currentPos);
System.arraycopy(_data, _currentPos, b, off, result);
_currentPos += result;
_overallStreamPos += result;