Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a2ccc4f1 authored by Jake Hamby's avatar Jake Hamby Committed by Android (Google) Code Review
Browse files

Add bounds checking for decoding CDMA SMS using Shift-JIS.

The test case testRandomUserData() in CdmaSmsCbTest fails since we
added support for decoding Shift-JIS messages. Change decodeShiftJis()
to call the helper method decodeCharset(), which checks the array
bounds and tries to decode as much as possible if the length extends
past the end of the PDU, instead of throwing
StringIndexOutOfBoundsException.

Bug: 8107987
Change-Id: I180e8360e391cd8276752a44a58a9c3a635dc284
parent 91187d41
Loading
Loading
Loading
Loading
+1 −5
Original line number Diff line number Diff line
@@ -1119,11 +1119,7 @@ public final class BearerData {
    private static String decodeShiftJis(byte[] data, int offset, int numFields)
        throws CodingException
    {
        try {
            return new String(data, offset, numFields - offset, "Shift_JIS");
        } catch (java.io.UnsupportedEncodingException ex) {
            throw new CodingException("Shift_JIS decode failed: " + ex);
        }
        return decodeCharset(data, offset, numFields, 1, "Shift_JIS");
    }

    private static void decodeUserDataPayload(UserData userData, boolean hasUserDataHeader)