diff options
-rw-r--r-- | libmm-glib/mm-common-helpers.c | 25 | ||||
-rw-r--r-- | libmm-glib/mm-common-helpers.h | 1 | ||||
-rw-r--r-- | src/mm-broadband-modem.c | 7 |
3 files changed, 32 insertions, 1 deletions
diff --git a/libmm-glib/mm-common-helpers.c b/libmm-glib/mm-common-helpers.c index 3f100b68..4694be8d 100644 --- a/libmm-glib/mm-common-helpers.c +++ b/libmm-glib/mm-common-helpers.c @@ -929,6 +929,31 @@ mm_utils_hexstr2bin (const gchar *hex, gsize *out_len) /* End from hostap */ +gboolean +mm_utils_ishexstr (const gchar *hex) +{ + gsize len; + gsize i; + + /* Length not multiple of 2? */ + len = strlen (hex); + if (len % 2 != 0) + return FALSE; + + for (i = 0; i < len; i++) { + /* Non-hex char? */ + if (hex[i] >= '0' && hex[i] <= '9') + continue; + if (hex[i] >= 'a' && hex[i] <= 'f') + continue; + if (hex[i] >= 'A' && hex[i] <= 'F') + continue; + return FALSE; + } + + return TRUE; +} + gchar * mm_utils_bin2hexstr (const guint8 *bin, gsize len) { diff --git a/libmm-glib/mm-common-helpers.h b/libmm-glib/mm-common-helpers.h index 6155b587..d23fc73e 100644 --- a/libmm-glib/mm-common-helpers.h +++ b/libmm-glib/mm-common-helpers.h @@ -99,6 +99,7 @@ const gchar *mm_sms_delivery_state_get_string_extended (guint delivery_state); gint mm_utils_hex2byte (const gchar *hex); gchar *mm_utils_hexstr2bin (const gchar *hex, gsize *out_len); gchar *mm_utils_bin2hexstr (const guint8 *bin, gsize len); +gboolean mm_utils_ishexstr (const gchar *hex); gboolean mm_utils_check_for_single_value (guint32 value); diff --git a/src/mm-broadband-modem.c b/src/mm-broadband-modem.c index ab26b345..a3f5ba47 100644 --- a/src/mm-broadband-modem.c +++ b/src/mm-broadband-modem.c @@ -4373,8 +4373,13 @@ decode_ussd_response (MMBroadbandModem *self, if (p) *p = '\0'; - decoded = mm_iface_modem_3gpp_ussd_decode (MM_IFACE_MODEM_3GPP_USSD (self), str, error); + /* If reply doesn't seem to be hex; just return itself... */ + if (!mm_utils_ishexstr (str)) + decoded = g_strdup (str); + else + decoded = mm_iface_modem_3gpp_ussd_decode (MM_IFACE_MODEM_3GPP_USSD (self), str, error); g_strfreev (items); + return decoded; } |