diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/altair/mm-modem-helpers-altair-lte.c | 18 | ||||
-rw-r--r-- | plugins/huawei/mm-broadband-modem-huawei.c | 4 | ||||
-rw-r--r-- | plugins/huawei/mm-modem-helpers-huawei.c | 30 |
3 files changed, 24 insertions, 28 deletions
diff --git a/plugins/altair/mm-modem-helpers-altair-lte.c b/plugins/altair/mm-modem-helpers-altair-lte.c index b71b458a..d2fd9af7 100644 --- a/plugins/altair/mm-modem-helpers-altair-lte.c +++ b/plugins/altair/mm-modem-helpers-altair-lte.c @@ -170,14 +170,14 @@ mm_altair_parse_vendor_pco_info (const gchar *pco_info, GError **error) } while (g_match_info_matches (match_info)) { - guint pco_cid; - g_autofree gchar *pco_id = NULL; - g_autofree gchar *pco_payload = NULL; - g_autofree gchar *pco_payload_bytes = NULL; - gsize pco_payload_bytes_len; - guint8 pco_prefix[6]; - GByteArray *pco_raw; - gsize pco_raw_len; + guint pco_cid; + g_autofree gchar *pco_id = NULL; + g_autofree gchar *pco_payload = NULL; + g_autofree guint8 *pco_payload_bytes = NULL; + gsize pco_payload_bytes_len; + guint8 pco_prefix[6]; + GByteArray *pco_raw; + gsize pco_raw_len; if (!mm_get_uint_from_match_info (match_info, 1, &pco_cid)) { g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED, @@ -246,7 +246,7 @@ mm_altair_parse_vendor_pco_info (const gchar *pco_info, GError **error) pco_raw = g_byte_array_sized_new (pco_raw_len); g_byte_array_append (pco_raw, pco_prefix, sizeof (pco_prefix)); - g_byte_array_append (pco_raw, (guint8 *)pco_payload_bytes, pco_payload_bytes_len); + g_byte_array_append (pco_raw, pco_payload_bytes, pco_payload_bytes_len); pco = mm_pco_new (); mm_pco_set_session_id (pco, pco_cid); diff --git a/plugins/huawei/mm-broadband-modem-huawei.c b/plugins/huawei/mm-broadband-modem-huawei.c index feaabd46..e2c90d14 100644 --- a/plugins/huawei/mm-broadband-modem-huawei.c +++ b/plugins/huawei/mm-broadband-modem-huawei.c @@ -2330,7 +2330,7 @@ decode (MMIfaceModem3gppUssd *self, const gchar *reply, GError **error) { - g_autofree gchar *bin = NULL; + g_autofree guint8 *bin = NULL; g_autofree guint8 *unpacked = NULL; gsize bin_len = 0; guint32 unpacked_len; @@ -2339,7 +2339,7 @@ decode (MMIfaceModem3gppUssd *self, if (!bin) return NULL; - unpacked = mm_charset_gsm_unpack ((guint8*) bin, (bin_len * 8) / 7, 0, &unpacked_len); + unpacked = mm_charset_gsm_unpack (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--; diff --git a/plugins/huawei/mm-modem-helpers-huawei.c b/plugins/huawei/mm-modem-helpers-huawei.c index 49f5a6ea..1b443052 100644 --- a/plugins/huawei/mm-modem-helpers-huawei.c +++ b/plugins/huawei/mm-modem-helpers-huawei.c @@ -157,14 +157,15 @@ mm_huawei_parse_ndisstatqry_response (const gchar *response, static gboolean match_info_to_ip4_addr (GMatchInfo *match_info, - guint match_index, - guint *out_addr) + guint match_index, + guint *out_addr) { - gchar *s, *bin = NULL; - gchar buf[9]; - gsize len, bin_len; - gboolean success = FALSE; - guint32 aux; + g_autofree gchar *s = NULL; + g_autofree guint8 *bin = NULL; + gchar buf[9]; + gsize len; + gsize bin_len; + guint32 aux; s = g_match_info_fetch (match_info, match_index); g_return_val_if_fail (s != NULL, FALSE); @@ -172,11 +173,11 @@ match_info_to_ip4_addr (GMatchInfo *match_info, len = strlen (s); if (len == 1 && s[0] == '0') { *out_addr = 0; - success = TRUE; - goto done; + return TRUE; } + if (len < 7 || len > 8) - goto done; + return FALSE; /* Handle possibly missing leading zero */ memset (buf, 0, sizeof (buf)); @@ -190,16 +191,11 @@ match_info_to_ip4_addr (GMatchInfo *match_info, bin = mm_utils_hexstr2bin (buf, -1, &bin_len, NULL); if (!bin || bin_len != 4) - goto done; + return FALSE; memcpy (&aux, bin, 4); *out_addr = GUINT32_SWAP_LE_BE (aux); - success = TRUE; - -done: - g_free (s); - g_free (bin); - return success; + return TRUE; } gboolean |