RFR: 8245036: DataInputStream.readFully(byte, int, int) does not throw expected IndexOutOfBoundsExceptions
brian.burkhalter at oracle.com
Thu Aug 6 21:42:56 UTC 2020
I think the source change is correct, it’s just that for a deterministic issue, the test generally will fail before the source change and pass with the source change applied. I did not investigate any further, either.
> On Aug 6, 2020, at 2:36 PM, Raffaello Giulietti <raffaello.giulietti at gmail.com> wrote:
> 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.
More information about the core-libs-dev