-
Bug
-
Resolution: Fixed
-
P4
-
13
As mentioned in the JDK-8210583 bug description about Base64.Encoder.encode throwing NegativeArraySizeException, the Base64.Decoder.decode method was also throwing NegativeArraySizeException while decoding the large arrays near Integer.MAX_VALUE, which is only because of the intermediate result integer overflow while computing the decoded output length, not the final result.
Instead of throwing OOME (as done byJDK-8210583 fix), the NegativeArraySizeException issue could have been resolved by storing that intermediate result with larger type "long" and then converting the final result to integer. So there is not need for OOME due to overflow as it does not happen with final result.
byte[] input = new byte[Integer.MAX_VALUE-2];
byte[] output = Base64.getDecoder().decode(input);
The above snippet throws OOME ("Decoded size is too large") even if the output length is less than Integer.MAX_VALUE
Instead of throwing OOME (as done by
byte[] input = new byte[Integer.MAX_VALUE-2];
byte[] output = Base64.getDecoder().decode(input);
The above snippet throws OOME ("Decoded size is too large") even if the output length is less than Integer.MAX_VALUE
- csr for
-
JDK-8217971 Remove OOME statement from Base64.Decoder
- Closed
- relates to
-
JDK-8210583 Base64.Encoder incorrectly throws NegativeArraySizeException
- Closed