aboutsummaryrefslogtreecommitdiff
path: root/src/mm-sms-utils.c
diff options
context:
space:
mode:
authorNathan Williams <njw@google.com>2011-07-25 00:48:14 -0500
committerDan Williams <dcbw@redhat.com>2011-07-25 01:18:35 -0500
commit061d4108886d2bdd4f5420515d1006b986fdfe95 (patch)
tree2d3aa2af6b427def0501f0e422ad9d0b873e476a /src/mm-sms-utils.c
parente20173dc47beed79367ac904e25e7c12d67fce33 (diff)
sms: calculate user-data bit padding correctly
Fourth and final in a series. This fixes an off-by-one (septet) error in the calculation of the amount of data to skip in the presence of a user data header, and adds the test case from the wild that triggered it.
Diffstat (limited to 'src/mm-sms-utils.c')
-rw-r--r--src/mm-sms-utils.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/mm-sms-utils.c b/src/mm-sms-utils.c
index 6b01cf5c..3f56a644 100644
--- a/src/mm-sms-utils.c
+++ b/src/mm-sms-utils.c
@@ -349,7 +349,11 @@ sms_parse_pdu (const char *hexpdu, GError **error)
udhl = pdu[user_data_offset] + 1;
user_data_offset += udhl;
if (user_data_encoding == MM_SMS_ENCODING_GSM7) {
- bit_offset = 7 - (udhl * 8) % 7;
+ /*
+ * Find the number of bits we need to add to the length of the
+ * user data to get a multiple of 7 (the padding).
+ */
+ bit_offset = (7 - udhl % 7) % 7;
user_data_len -= (udhl * 8 + bit_offset) / 7;
} else
user_data_len -= udhl;