aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mm-sms-part-cdma.c6
-rw-r--r--src/tests/test-sms-part-cdma.c23
2 files changed, 29 insertions, 0 deletions
diff --git a/src/mm-sms-part-cdma.c b/src/mm-sms-part-cdma.c
index 581bed57..a579121b 100644
--- a/src/mm-sms-part-cdma.c
+++ b/src/mm-sms-part-cdma.c
@@ -915,6 +915,12 @@ read_bearer_data_user_data (MMSmsPart *sms_part,
guint i;
guint num_bytes;
+ if (num_fields == 0) {
+ mm_obj_dbg (log_object, " text: ''");
+ mm_sms_part_set_text (sms_part, "");
+ break;
+ }
+
/* 2 bytes per field! */
num_bytes = num_fields * 2;
diff --git a/src/tests/test-sms-part-cdma.c b/src/tests/test-sms-part-cdma.c
index eb095f34..935a9c6b 100644
--- a/src/tests/test-sms-part-cdma.c
+++ b/src/tests/test-sms-part-cdma.c
@@ -348,6 +348,28 @@ test_unicode_encoding (void)
"中國哲學書電子化計劃");
}
+static void
+test_empty_unicode_user_data (void)
+{
+ static const guint8 pdu[] = {
+ 0x01, 0x08, 0x2f, 0x03, 0x01, 0x00, 0x00, 0x00,
+ 0xfd, 0x00, 0x01, 0x02, 0x08, 0x00, 0x01, 0x02,
+ 0x00, 0x00, 0x01, 0x02, 0x20, 0x01, 0x02, 0x00,
+ 0x00, 0x00, 0x47, 0x06, 0x01, 0x02, 0x00, 0x06,
+ 0x08, 0x08, 0x05, 0x01, 0x06, 0x01, 0x6d, 0x38,
+ 0x00, 0x03, 0x05, 0x01, 0x06, 0x01, 0x02, 0x00,
+ 0x06, 0x08, 0x08, 0x05, 0x01, 0x00, 0x00, 0x00,
+ 0x47, 0x06, 0x01, 0x02, 0x00, 0x06, 0x08, 0x08,
+ 0x05, 0x01, 0x06, 0x01, 0x6d, 0x38, 0x00, 0x03,
+ 0x05, 0x01, 0x06, 0x01, 0x02, 0x00, 0x06, 0x08,
+ 0x08, 0x05, 0x01, 0x06, 0x06, 0x00, 0x01, 0x00,
+ 0x34, 0x00, 0x03, 0x05, 0x29, 0x08, 0x08, 0x05,
+ 0x01, 0xb6, 0x01, 0x38, 0x00, 0x02, 0x02, 0x00 };
+
+ /* also invalid this one */
+ common_test_invalid_part_from_pdu (pdu, sizeof (pdu));
+}
+
/********************* PDU CREATOR TESTS *********************/
static void
@@ -553,6 +575,7 @@ int main (int argc, char **argv)
g_test_add_func ("/MM/SMS/CDMA/PDU-Parser/latin-encoding", test_latin_encoding);
g_test_add_func ("/MM/SMS/CDMA/PDU-Parser/latin-encoding-2", test_latin_encoding_2);
g_test_add_func ("/MM/SMS/CDMA/PDU-Parser/unicode-encoding", test_unicode_encoding);
+ g_test_add_func ("/MM/SMS/CDMA/PDU-Parser/empty-unicode-user-data", test_empty_unicode_user_data);
g_test_add_func ("/MM/SMS/CDMA/PDU-Creator/ascii-encoding", test_create_pdu_text_ascii_encoding);
g_test_add_func ("/MM/SMS/CDMA/PDU-Creator/latin-encoding", test_create_pdu_text_latin_encoding);