JDK-8165243 : Base64.Encoder.wrap(os).write(byte[],int,int) with incorrect arguments should not produce output
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util
  • Affected Version: 9
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2016-09-01
  • Updated: 2017-11-29
  • Resolved: 2016-09-03
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 JDK 9
8u152Fixed 9 b135Fixed
Description
An output stream 'es' can be obtained as encoder.wrap(os).
Normally, es.write(buf, off, len) throws IndexOutOfBoundException, if the referenced portion lies outside the buffer.  In this case, nothing is written to the underlying output stream 'os'.

However, if (off + len) numerically overflows, then the call to write() will produce some output and only when reached the boundary of the buf will throw the exception.

This behavior looks inconsistent.