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

Commit 83d54a44 authored by Yuta Ui's avatar Yuta Ui Committed by Zoran Jovanovic
Browse files

Fix check of the size of the alpha identifier

This change fixes an issue that FDN number is unexpectedly overwritten
by wrongly encoded FDN name. The issue can happen if user enter FDN name
which contains multibyte character.

That is because AdnRecord does not check the length of the alpha
identifier correctly. mAlphaTag.length() does not return the size of the
alpha identifier but returns the number of characters.

Change-Id: I109a01eea6519a6a09a8bf7a143eaafd8c04025e
parent 20955c93
Loading
Loading
Loading
Loading
+8 −5
Original line number Diff line number Diff line
@@ -226,9 +226,13 @@ public class AdnRecord implements Parcelable {
            Rlog.w(LOG_TAG,
                    "[buildAdnString] Max length of dialing number is 20");
            return null;
        } else if (mAlphaTag != null && mAlphaTag.length() > footerOffset) {
            Rlog.w(LOG_TAG,
                    "[buildAdnString] Max length of tag is " + footerOffset);
        }

        byteTag = !TextUtils.isEmpty(mAlphaTag) ? GsmAlphabet.stringToGsm8BitPacked(mAlphaTag)
                : new byte[0];

        if (byteTag.length > footerOffset) {
            Rlog.w(LOG_TAG, "[buildAdnString] Max length of tag is " + footerOffset);
            return null;
        } else {
            bcdNumber = PhoneNumberUtils.numberToCalledPartyBCD(mNumber);
@@ -243,8 +247,7 @@ public class AdnRecord implements Parcelable {
            adnString[footerOffset + ADN_EXTENSION_ID]
                    = (byte) 0xFF; // Extension Record Id

            if (!TextUtils.isEmpty(mAlphaTag)) {
                byteTag = GsmAlphabet.stringToGsm8BitPacked(mAlphaTag);
            if (byteTag.length > 0) {
                System.arraycopy(byteTag, 0, adnString, 0, byteTag.length);
            }