diff options
author | Denis Kenzior <denkenz@gmail.com> | 2010-02-23 01:06:35 -0600 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2010-02-23 12:03:03 -0600 |
commit | 0db01081200f80092deeeef40e6d08ecb04a2d99 (patch) | |
tree | 5c909b38d0d84a5f498820d5a046c4b1f44b8cb4 /src/simutil.c | |
parent | 5a86a7408aa248d9f3eb5bd5dc790f18ff03e0ec (diff) | |
download | ofono-0db01081200f80092deeeef40e6d08ecb04a2d99.tar.bz2 |
Fix: EFspdi parsing
EFspdi is a nested BER-TLV structure. The outside BER-TLV has the tag
A3, and the inside contains the PLMN list TLV with tag 0x80.
Diffstat (limited to 'src/simutil.c')
-rw-r--r-- | src/simutil.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/simutil.c b/src/simutil.c index 9b457124..11411b68 100644 --- a/src/simutil.c +++ b/src/simutil.c @@ -378,22 +378,30 @@ struct sim_spdi { struct sim_spdi *sim_spdi_new(const guint8 *tlv, int length) { + const guint8 *plmn_list_tlv; const guint8 *plmn_list; struct sim_spdi *spdi; struct spdi_operator *oper; int tlv_length; + int list_length; - if (length <= 5) + if (length < 7) return NULL; - plmn_list = ber_tlv_find_by_tag(tlv, 0x80, length, &tlv_length); + plmn_list_tlv = ber_tlv_find_by_tag(tlv, 0xA3, length, &tlv_length); + + if (plmn_list_tlv == NULL) + return NULL; + + plmn_list = ber_tlv_find_by_tag(plmn_list_tlv, 0x80, tlv_length, + &list_length); if (!plmn_list) return NULL; spdi = g_new0(struct sim_spdi, 1); - for (tlv_length /= 3; tlv_length--; plmn_list += 3) { + for (list_length /= 3; list_length--; plmn_list += 3) { if ((plmn_list[0] & plmn_list[1] & plmn_list[2]) == 0xff) continue; |