Bug 824605 - Fix readLen in getSPDI. r=allstars.chh

This commit is contained in:
Patrick Wang 2012-12-25 19:27:48 +08:00
parent a71861c533
commit 5bcd5447b3

View File

@ -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,