From 2f06242dcd23f9c1062e2534b52056d24e763330 Mon Sep 17 00:00:00 2001 From: Patrick Wang Date: Tue, 25 Dec 2012 19:27:48 +0800 Subject: [PATCH] Bug 824605 - Fix readLen in getSPDI. r=allstars.chh --- dom/system/gonk/ril_worker.js | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/dom/system/gonk/ril_worker.js b/dom/system/gonk/ril_worker.js index 2f6fa5b60f5..7810b847f64 100644 --- a/dom/system/gonk/ril_worker.js +++ b/dom/system/gonk/ril_worker.js @@ -1555,39 +1555,34 @@ let RIL = { */ getSPDI: function getSPDI() { function callback() { - if (DEBUG) debug("SPDI: Process SPDI callback"); let length = Buf.readUint32(); - let tlvTag; - let tlvLen; let readLen = 0; let endLoop = false; this.iccInfoPrivate.SPDI = null; - while ((readLen < length) && !endLoop) { - tlvTag = GsmPDUHelper.readHexOctet(); - tlvLen = GsmPDUHelper.readHexOctet(); - readLen += 2; // For tag and length. + while ((readLen < length / 2) && !endLoop) { + let tlvTag = GsmPDUHelper.readHexOctet(); + let tlvLen = GsmPDUHelper.readHexOctet(); + readLen += 2; // For tag and length fields. switch (tlvTag) { case SPDI_TAG_SPDI: // The value part itself is a TLV. continue; case SPDI_TAG_PLMN_LIST: // This PLMN list is what we want. - this.iccInfoPrivate.SPDI = this.readPLMNEntries(tlvLen/3); + this.iccInfoPrivate.SPDI = this.readPLMNEntries(tlvLen / 3); readLen += tlvLen; endLoop = true; break; default: // We don't care about its content if its tag is not SPDI nor // PLMN_LIST. - GsmPDUHelper.readHexOctetArray(tlvLen); - readLen += tlvLen; + endLoop = true; + break; } } // Consume unread octets. - if (length - readLen > 0) { - GsmPDUHelper.readHexOctetArray(length - readLen); - } + Buf.seekIncoming((length / 2 - readLen) * PDU_HEX_OCTET_SIZE); Buf.readStringDelimiter(length); if (DEBUG) debug("SPDI: " + JSON.stringify(this.iccInfoPrivate.SPDI)); @@ -1596,7 +1591,7 @@ let RIL = { } } - // PLMN List is Servive 51 in USIM, EF_SPDI + // PLMN List is Service 51 in USIM, EF_SPDI this.iccIO({ command: ICC_COMMAND_GET_RESPONSE, fileId: ICC_EF_SPDI,