summaryrefslogtreecommitdiffstats
path: root/src/simutil.c
diff options
context:
space:
mode:
authorAlfonso Sanchez-Beato <alfonso.sanchez-beato@canonical.com>2014-03-14 17:23:43 +0100
committerDenis Kenzior <denkenz@gmail.com>2014-03-14 12:24:26 -0500
commit46de4df677d4dc70ef6e64ed5f6ea0c71b36099d (patch)
tree90b236af153a6d22ad0cda8e42ee86389d02e687 /src/simutil.c
parent6a96eea978ed84912c8935a303c12f37a234f8a9 (diff)
downloadofono-46de4df677d4dc70ef6e64ed5f6ea0c71b36099d.tar.bz2
simutil: Fix EF_PNN access
EF_PNN was not being read properly (see TS 24.008, section 10.5.3.5a, for network names format), which affected the displayed PLMN name for some MVNOs. Some modems already read the file and return the right string: these do not show the problem.
Diffstat (limited to 'src/simutil.c')
-rw-r--r--src/simutil.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/simutil.c b/src/simutil.c
index 90d7f8d2..a7745ae2 100644
--- a/src/simutil.c
+++ b/src/simutil.c
@@ -767,12 +767,14 @@ static char *sim_network_name_parse(const unsigned char *buffer, int length,
gboolean *add_ci)
{
char *ret = NULL;
- unsigned char *endp;
unsigned char dcs;
int i;
gboolean ci = FALSE;
+ unsigned char *unpacked_buf;
+ long num_char, written;
+ int spare_bits;
- if (length < 1)
+ if (length < 2)
return NULL;
dcs = *buffer++;
@@ -787,11 +789,18 @@ static char *sim_network_name_parse(const unsigned char *buffer, int length,
switch (dcs & (7 << 4)) {
case 0x00:
- endp = memchr(buffer, 0xff, length);
- if (endp)
- length = endp - buffer;
- ret = convert_gsm_to_utf8(buffer, length,
- NULL, NULL, 0xff);
+ spare_bits = dcs & 0x07;
+ num_char = (length * 8 - spare_bits) / 7;
+
+ unpacked_buf = unpack_7bit(buffer, length, 0, FALSE,
+ num_char, &written, 0);
+ if (unpacked_buf == NULL)
+ break;
+
+ ret = convert_gsm_to_utf8(unpacked_buf, written, NULL, NULL, 0);
+
+ g_free(unpacked_buf);
+
break;
case 0x10:
if ((length % 2) == 1) {