Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
None
Description
OzoneFSInputStream#read(ByteBuffer) uses the target buffer's position for offsetting into the temporary array:
public int read(ByteBuffer buf) throws IOException { int bufInitPos = buf.position(); int readLen = Math.min(buf.remaining(), inputStream.available()); byte[] readData = new byte[readLen]; int bytesRead = inputStream.read(readData, bufInitPos, readLen); buf.put(readData);
Given a buffer with capacity=10 and position=8, this results in the following:
- readLen = 2 => readData.length = 2
- bufInitPos = 8
So inputStream reads 2 bytes and writes it into readData starting at offset 8, which results in an IndexOutOfBoundsException.
offset should always be 0, since the temporary array is sized exactly for the length to read, and it has no extra data at the start.
Attachments
Issue Links
- links to