mm-sms-part-3gpp: sms_decode_text: avoid decoding an empty text message

Fix segfault that can occur during message text decoding if there are no
elements in SMS text
This commit is contained in:
Dmitry Skorykh
2022-06-24 13:35:40 +03:00
parent db33a43b45
commit a87a1f8ced

View File

@@ -252,6 +252,14 @@ sms_decode_text (const guint8 *text,
gpointer log_object, gpointer log_object,
GError **error) GError **error)
{ {
if (!text || len == 0) {
g_set_error (error,
MM_CORE_ERROR,
MM_CORE_ERROR_FAILED,
"Skipping SMS text: SMS text has no elements to decode");
return NULL;
}
if (encoding == MM_SMS_ENCODING_GSM7) { if (encoding == MM_SMS_ENCODING_GSM7) {
g_autoptr(GByteArray) unpacked_array = NULL; g_autoptr(GByteArray) unpacked_array = NULL;
guint8 *unpacked = NULL; guint8 *unpacked = NULL;