libmm-glib,common-helpers: make hexstr2bin() accept input string length

Optionally given explicitly, and -1 can be used to assume it's
NUL-terminated.
This commit is contained in:
Aleksander Morgado
2021-02-23 11:35:11 +00:00
parent 657cabcfce
commit a211981d4a
11 changed files with 16 additions and 15 deletions
+2 -2
View File
@@ -1311,7 +1311,7 @@ parse_mnc_length (const gchar *response,
g_autofree gchar *bin = NULL;
/* Convert hex string to binary */
bin = mm_utils_hexstr2bin (hex, &buflen, error);
bin = mm_utils_hexstr2bin (hex, -1, &buflen, error);
if (!bin) {
g_prefix_error (error, "SIM returned malformed response '%s': ", hex);
return 0;
@@ -1416,7 +1416,7 @@ parse_spn (const gchar *response,
g_autofree gchar *bin = NULL;
/* Convert hex string to binary */
bin = mm_utils_hexstr2bin (hex, &buflen, error);
bin = mm_utils_hexstr2bin (hex, -1, &buflen, error);
if (!bin) {
g_prefix_error (error, "SIM returned malformed response '%s': ", hex);
return NULL;
+1 -1
View File
@@ -169,7 +169,7 @@ mm_modem_charset_hex_to_utf8 (const gchar *src,
iconv_from = charset_iconv_from (charset);
g_return_val_if_fail (iconv_from != NULL, FALSE);
unconverted = mm_utils_hexstr2bin (src, &unconverted_len, NULL);
unconverted = mm_utils_hexstr2bin (src, -1, &unconverted_len, NULL);
if (!unconverted)
return NULL;
+1 -1
View File
@@ -1815,7 +1815,7 @@ mm_firmware_unique_id_to_qmi_unique_id (const gchar *unique_id,
gsize tmp_len;
tmp_len = 0;
tmp = (guint8 *) mm_utils_hexstr2bin (unique_id, &tmp_len, error);
tmp = (guint8 *) mm_utils_hexstr2bin (unique_id, -1, &tmp_len, error);
if (!tmp) {
g_prefix_error (error, "Unexpected character found in unique id: ");
return NULL;
+1 -1
View File
@@ -4291,7 +4291,7 @@ mm_3gpp_parse_emergency_numbers (const char *raw, GError **error)
return NULL;
}
bin = (guint8 *) mm_utils_hexstr2bin (raw, &binlen, error);
bin = (guint8 *) mm_utils_hexstr2bin (raw, -1, &binlen, error);
if (!bin) {
g_prefix_error (error, "invalid raw emergency numbers list contents: ");
return NULL;
+1 -1
View File
@@ -343,7 +343,7 @@ mm_sms_part_3gpp_new_from_pdu (guint index,
gsize pdu_len;
/* Convert PDU from hex to binary */
pdu = (guint8 *) mm_utils_hexstr2bin (hexpdu, &pdu_len, error);
pdu = (guint8 *) mm_utils_hexstr2bin (hexpdu, -1, &pdu_len, error);
if (!pdu) {
g_prefix_error (error, "Couldn't convert 3GPP PDU from hex to binary: ");
return NULL;
+1 -1
View File
@@ -321,7 +321,7 @@ mm_sms_part_cdma_new_from_pdu (guint index,
gsize pdu_len;
/* Convert PDU from hex to binary */
pdu = (guint8 *) mm_utils_hexstr2bin (hexpdu, &pdu_len, error);
pdu = (guint8 *) mm_utils_hexstr2bin (hexpdu, -1, &pdu_len, error);
if (!pdu) {
g_prefix_error (error, "Couldn't convert CDMA PDU from hex to binary: ");
return NULL;