sms-part-cdma: fix warning when attempting g_convert() with NULL input

GLib-CRITICAL **: 21:21:51.419: g_convert: assertion 'str != NULL' failed

  Program received signal SIGTRAP, Trace/breakpoint trap.
  0x00007ffff7db3e82 in g_logv () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
  (gdb) bt
  #0  0x00007ffff7db3e82 in g_logv () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
  #1  0x00007ffff7db40ef in g_log () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
  #2  0x00007ffff7d8a5da in g_convert () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
  #3  0x00005555555592cf in read_bearer_data_user_data (log_object=0x0, subparameter=<optimized out>, sms_part=0x555555578000)
      at ../src/mm-sms-part-cdma.c:929
  #4  read_bearer_data (log_object=0x0, parameter=<optimized out>, sms_part=0x555555578000) at ../src/mm-sms-part-cdma.c:982
  #5  mm_sms_part_cdma_new_from_binary_pdu
This commit is contained in:
Aleksander Morgado
2023-03-30 21:30:54 +00:00
parent fae6d20ed0
commit 6dccfc5abd
2 changed files with 29 additions and 0 deletions

View File

@@ -915,6 +915,12 @@ read_bearer_data_user_data (MMSmsPart *sms_part,
guint i; guint i;
guint num_bytes; 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! */ /* 2 bytes per field! */
num_bytes = num_fields * 2; num_bytes = num_fields * 2;

View File

@@ -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 *********************/ /********************* PDU CREATOR TESTS *********************/
static void 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", 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/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/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/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); g_test_add_func ("/MM/SMS/CDMA/PDU-Creator/latin-encoding", test_create_pdu_text_latin_encoding);