diff options
| author | 2009-07-01 22:44:16 -0700 | |
|---|---|---|
| committer | 2009-07-01 22:44:16 -0700 | |
| commit | 730babbd5e2bdd45b80b1d16f0d4ebb653e6574e (patch) | |
| tree | dcea2cd3ae8ee6edc648d25684dbd0eeaec4be2f | |
| parent | 023d7564a6b6bce894aba4eaf00133c6f86d1de5 (diff) | |
| parent | 85d650c89998eb108faa2c02dcc32467e23f9555 (diff) | |
am 85d650c8: Merge change 5804 into donut
Merge commit '85d650c89998eb108faa2c02dcc32467e23f9555'
* commit '85d650c89998eb108faa2c02dcc32467e23f9555':
Ensure that we never trigger ArrayIndexOutOfBoundsException by checking that
| -rw-r--r-- | telephony/java/com/android/internal/telephony/WspTypeDecoder.java | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/telephony/java/com/android/internal/telephony/WspTypeDecoder.java b/telephony/java/com/android/internal/telephony/WspTypeDecoder.java index 2984fa8a576c..3bbe0e17a86e 100644 --- a/telephony/java/com/android/internal/telephony/WspTypeDecoder.java +++ b/telephony/java/com/android/internal/telephony/WspTypeDecoder.java @@ -187,22 +187,30 @@ public class WspTypeDecoder { } /** - * Decode the "Extension-media" type for WSP pdu - * - * @param startIndex The starting position of the "Extension-media" in this pdu - * - * @return false when error(not a Extension-media) occur - * return value can be retrieved by getValueString() method - * length of data in pdu can be retrieved by getValue32() method - */ + * Decode the "Extension-media" type for WSP PDU. + * + * @param startIndex The starting position of the "Extension-media" in this PDU. + * + * @return false on error, such as if there is no Extension-media at startIndex. + * Side-effects: updates stringValue (available with getValueString()), which will be + * null on error. The length of the data in the PDU is available with getValue32(), 0 + * on error. + */ public boolean decodeExtensionMedia(int startIndex) { int index = startIndex; - while (wspData[index] != 0) { + dataLength = 0; + stringValue = null; + int length = wspData.length; + boolean rtrn = index < length; + + while (index < length && wspData[index] != 0) { index++; } + dataLength = index - startIndex + 1; stringValue = new String(wspData, startIndex, dataLength - 1); - return true; + + return rtrn; } /** |