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

Commit bfb0076f authored by Android Build Merger (Role)'s avatar Android Build Merger (Role)
Browse files

[automerger] Fixed Invalid Pdu Issue am: 4b938358 am: fc2a2d07 am:...

[automerger] Fixed Invalid Pdu Issue am: 4b938358 am: fc2a2d07 am: ca00d5d1 am: 23de93c1 am: 909c1606

Change-Id: Ib70c66d68e59840a4930c8844b4b731c10a32d48
parents 492d873b 909c1606
Loading
Loading
Loading
Loading
+29 −0
Original line number Diff line number Diff line
@@ -67,6 +67,7 @@ import android.telephony.SmsMessage;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.EventLog;

import com.android.internal.R;
import com.android.internal.annotations.VisibleForTesting;
@@ -729,6 +730,18 @@ public abstract class InboundSmsHandler extends StateMachine {
        byte[][] pdus;
        int destPort = tracker.getDestPort();

        // Do not process when the message count is invalid.
        if (messageCount <= 0) {
            EventLog.writeEvent(
                    0x534e4554 /* snetTagId */,
                    "72298611" /* buganizer id */,
                    -1 /* uid */,
                    String.format(
                        "processMessagePart: invalid messageCount = %d",
                        messageCount));
            return false;
        }

        if (messageCount == 1) {
            // single-part message
            pdus = new byte[][]{tracker.getPdu()};
@@ -762,6 +775,22 @@ public abstract class InboundSmsHandler extends StateMachine {
                    // subtract offset to convert sequence to 0-based array index
                    int index = cursor.getInt(SEQUENCE_COLUMN) - tracker.getIndexOffset();

                    // The invalid PDUs can be received and stored in the raw table. The range
                    // check ensures the process not crash even if the seqNumber in the
                    // UserDataHeader is invalid.
                    if (index >= pdus.length || index < 0) {
                        EventLog.writeEvent(
                                0x534e4554 /* snetTagId */,
                                "72298611" /* buganizer id */,
                                -1 /* uid */,
                                String.format(
                                    "processMessagePart: invalid seqNumber = %d, "
                                    + "messageCount = %d",
                                    index + tracker.getIndexOffset(),
                                    messageCount));
                        continue;
                    }

                    pdus[index] = HexDump.hexStringToByteArray(cursor.getString(PDU_COLUMN));

                    // Read the destination port from the first segment (needed for CDMA WAP PDU).