libmm-glib,common-helpers: make hexstr2bin() return a GError
This util method checks whether the input string is a valid hex string, so make sure we return a GError on failure.
This commit is contained in:
@@ -2330,21 +2330,20 @@ decode (MMIfaceModem3gppUssd *self,
|
||||
const gchar *reply,
|
||||
GError **error)
|
||||
{
|
||||
gchar *bin, *utf8;
|
||||
guint8 *unpacked;
|
||||
gsize bin_len;
|
||||
guint32 unpacked_len;
|
||||
g_autofree gchar *bin = NULL;
|
||||
g_autofree guint8 *unpacked = NULL;
|
||||
gsize bin_len = 0;
|
||||
guint32 unpacked_len;
|
||||
|
||||
bin = mm_utils_hexstr2bin (reply, &bin_len, error);
|
||||
if (!bin)
|
||||
return NULL;
|
||||
|
||||
bin = mm_utils_hexstr2bin (reply, &bin_len);
|
||||
unpacked = mm_charset_gsm_unpack ((guint8*) bin, (bin_len * 8) / 7, 0, &unpacked_len);
|
||||
/* if the last character in a 7-byte block is padding, then drop it */
|
||||
if ((bin_len % 7 == 0) && (unpacked[unpacked_len - 1] == 0x0d))
|
||||
unpacked_len--;
|
||||
utf8 = (char*) mm_charset_gsm_unpacked_to_utf8 (unpacked, unpacked_len);
|
||||
|
||||
g_free (bin);
|
||||
g_free (unpacked);
|
||||
return utf8;
|
||||
return (gchar*) mm_charset_gsm_unpacked_to_utf8 (unpacked, unpacked_len);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
@@ -188,7 +188,7 @@ match_info_to_ip4_addr (GMatchInfo *match_info,
|
||||
else
|
||||
g_assert_not_reached ();
|
||||
|
||||
bin = mm_utils_hexstr2bin (buf, &bin_len);
|
||||
bin = mm_utils_hexstr2bin (buf, &bin_len, NULL);
|
||||
if (!bin || bin_len != 4)
|
||||
goto done;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user