RFR: 8322877: java/io/BufferedInputStream/TransferTo.java failed with IndexOutOfBoundsException

Markus KARG duke at openjdk.org
Thu Jan 4 18:40:32 UTC 2024


On Thu, 4 Jan 2024 18:35:49 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

>> src/java.base/share/classes/java/io/BufferedInputStream.java line 650:
>> 
>>> 648:                 } else {
>>> 649:                     // Prevent poisoning and leaking of buf
>>> 650:                     byte[] buffer = Arrays.copyOfRange(getBufIfOpen(), pos, count);
>> 
>> @bplb Shouldn't it be `avail` *here*, too?
>
> No: the third param of [Arrays.copyOfRange](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/Arrays.html#copyOfRange(byte[],int,int)) is `to`, not `len`.

Ah, this explains why it did not fail originally, but only after adding the "isTrusted" case! 🙏

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/17250#discussion_r1442124151


More information about the core-libs-dev mailing list