RFR: 8245036: DataInputStream.readFully(byte, int, int) does not throw expected IndexOutOfBoundsExceptions
raffaello.giulietti at gmail.com
Thu Aug 6 21:36:04 UTC 2020
the body of readFully() seems to silently assume that the other
arguments are correct (e.g., off >= 0 and so on).
In the (still) current implementation of
DataInputStream.readFully(byte, int, int), when off < 0 and len > 0,
in the loop it then invokes the underlying in.read(byte, int, int)
with a negative offset off + n during the initial iterations.
In the specific case of the tests on underlying FileInputStreams, it
thus seems that read(byte, int, int) does not, in turn, validate its
arguments. I didn't investigate further, although I will in the next
days if deemed necessary.
On 2020-08-06 22:09, Brian Burkhalter wrote:
>> On Aug 6, 2020, at 12:36 PM, Raffaello Giulietti
>> <raffaello.giulietti at gmail.com <mailto:raffaello.giulietti at gmail.com>>
>>> This looks all right. I would be inclined to do like in  and throw
>>> the RuntimeException on the line after each readFully() and drop the
>>> return statements], but I’m not going to insist on it.
>> Sorry, I didn't completely get that.
>> Here we are!
> This looks good. I observed however that the test passes without the
> change to DataInputStream.
More information about the core-libs-dev