From f4e912311f68f281822def0421bc2ed68c3c6f9c Mon Sep 17 00:00:00 2001 From: mullan Date: Wed, 12 Oct 2016 09:46:35 -0400 Subject: [PATCH] 8162723: Array index overflow in Base64 utility class Reviewed-by: ascarpino, jnimeh --- .../org/apache/xml/internal/security/utils/Base64.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/Base64.java b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/Base64.java index db1f49eae..741f3c1a8 100644 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/Base64.java +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/Base64.java @@ -376,14 +376,14 @@ public class Base64 { return null; } - int lengthDataBits = binaryData.length * EIGHTBIT; - if (lengthDataBits == 0) { + long lengthDataBits = ((long) binaryData.length) * ((long) EIGHTBIT); + if (lengthDataBits == 0L) { return ""; } - int fewerThan24bits = lengthDataBits % TWENTYFOURBITGROUP; - int numberTriplets = lengthDataBits / TWENTYFOURBITGROUP; - int numberQuartet = fewerThan24bits != 0 ? numberTriplets + 1 : numberTriplets; + long fewerThan24bits = lengthDataBits % TWENTYFOURBITGROUP; + int numberTriplets = (int) (lengthDataBits / TWENTYFOURBITGROUP); + int numberQuartet = fewerThan24bits != 0L ? numberTriplets + 1 : numberTriplets; int quartesPerLine = length / 4; int numberLines = (numberQuartet - 1) / quartesPerLine; char encodedData[] = null; -- GitLab