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

Commit 216973ae authored by Nathan Harold's avatar Nathan Harold Committed by Grace Chen
Browse files

Improve the Safety Checks on IccCardStatus.toString()

Tighter range checks in the toString() method to cross
validate the application array against the app indices.

Bug: 62459080
Test: none
Change-Id: I078315f5ea773eb117303cccfcedda06280fffab
(cherry picked from commit 257732fb)
parent 53178817
Loading
Loading
Loading
Loading
+12 −9
Original line number Original line Diff line number Diff line
@@ -116,30 +116,33 @@ public class IccCardStatus {
        StringBuilder sb = new StringBuilder();
        StringBuilder sb = new StringBuilder();
        sb.append("IccCardState {").append(mCardState).append(",")
        sb.append("IccCardState {").append(mCardState).append(",")
        .append(mUniversalPinState)
        .append(mUniversalPinState)
        .append(",num_apps=").append(mApplications.length)
        .append(",num_apps=").append(mApplications.length);
        .append(",gsm_id=").append(mGsmUmtsSubscriptionAppIndex);

        if (mGsmUmtsSubscriptionAppIndex >=0
        sb.append(",gsm_id=").append(mGsmUmtsSubscriptionAppIndex);
                && mGsmUmtsSubscriptionAppIndex <CARD_MAX_APPS) {
        if (mApplications != null
                && mGsmUmtsSubscriptionAppIndex >= 0
                && mGsmUmtsSubscriptionAppIndex < mApplications.length) {
            app = mApplications[mGsmUmtsSubscriptionAppIndex];
            app = mApplications[mGsmUmtsSubscriptionAppIndex];
            sb.append(app == null ? "null" : app);
            sb.append(app == null ? "null" : app);
        }
        }


        sb.append(",cdma_id=").append(mCdmaSubscriptionAppIndex);
        sb.append(",cdma_id=").append(mCdmaSubscriptionAppIndex);
        if (mCdmaSubscriptionAppIndex >=0
        if (mApplications != null
                && mCdmaSubscriptionAppIndex <CARD_MAX_APPS) {
                && mCdmaSubscriptionAppIndex >= 0
                && mCdmaSubscriptionAppIndex < mApplications.length) {
            app = mApplications[mCdmaSubscriptionAppIndex];
            app = mApplications[mCdmaSubscriptionAppIndex];
            sb.append(app == null ? "null" : app);
            sb.append(app == null ? "null" : app);
        }
        }


        sb.append(",ims_id=").append(mImsSubscriptionAppIndex);
        sb.append(",ims_id=").append(mImsSubscriptionAppIndex);
        if (mImsSubscriptionAppIndex >=0
        if (mApplications != null
                && mImsSubscriptionAppIndex <CARD_MAX_APPS) {
                && mImsSubscriptionAppIndex >= 0
                && mImsSubscriptionAppIndex < mApplications.length) {
            app = mApplications[mImsSubscriptionAppIndex];
            app = mApplications[mImsSubscriptionAppIndex];
            sb.append(app == null ? "null" : app);
            sb.append(app == null ? "null" : app);
        }
        }


        sb.append("}");
        sb.append("}");

        return sb.toString();
        return sb.toString();
    }
    }