summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Mork <bjorn@mork.no>2016-02-08 14:18:14 +0100
committerDan Williams <dcbw@redhat.com>2016-02-08 09:36:07 -0600
commit6f988368fdac492fa4289ae1c633c84d7abc39c6 (patch)
tree8d2d534bee1fd864eae3d70741232363b5ab57b5
parent4aed63cf6b69651bf6df91a5b99ce76a54c98788 (diff)
qmicli: fix PLMN printing
BCD PLMNs with 2 digit MNCs will have an 'F' digit between the MCC and the MNC. This maps to \0, which would cause a truncated result string with only the MCC. Signed-off-by: Bjørn Mork <bjorn@mork.no>
-rw-r--r--src/qmicli/qmicli-nas.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/qmicli/qmicli-nas.c b/src/qmicli/qmicli-nas.c
index 9d43d46..c774bf4 100644
--- a/src/qmicli/qmicli-nas.c
+++ b/src/qmicli/qmicli-nas.c
@@ -2233,8 +2233,12 @@ str_from_bcd_plmn (const gchar *bcd)
str = g_malloc (7);
for (i = 0, j = 0 ; i < 3; i++) {
- str[j++] = bcd_chars[bcd[i] & 0xF];
- str[j++] = bcd_chars[(bcd[i] >> 4) & 0xF];
+ str[j] = bcd_chars[bcd[i] & 0xF];
+ if (str[j])
+ j++;
+ str[j] = bcd_chars[(bcd[i] >> 4) & 0xF];
+ if (str[j])
+ j++;
}
str[j] = '\0';