On Tue, 3 Nov 2020 00:04:58 GMT, Brian Burkhalter <b...@openjdk.org> wrote:

> InputStream::readNBytes() invokes read(byte[],int,int) repeatedly to load 
> bytes into a sequence of intermediate arrays. If an intermediate array is not 
> completely filled before being added to the list of arrays the contents of 
> which are eventually concatenated to produce the result, then the unfilled 
> part of the intermediate array will contribute zeros to the result which are 
> not actually in the input. This can occur for example if n < 8192 bytes are 
> read into an intermediate array without filling it, and the next read() 
> returns zero. It is proposed to detect when an intermediate array is only 
> partially full, and to copy the valid range of the array into a new array 
> which is instead appended to the list of component arrays.

This pull request has now been integrated.

Changeset: c287170c
Author:    Brian Burkhalter <b...@openjdk.org>
URL:       https://git.openjdk.java.net/jdk/commit/c287170c
Stats:     43 lines in 2 files changed: 39 ins; 1 del; 3 mod

8254742: InputStream::readNBytes(int) result may contain zeros not in input

Reviewed-by: shade, bchristi

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

PR: https://git.openjdk.java.net/jdk/pull/1024

Reply via email to