diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2020-11-22 16:55:22 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2020-12-19 10:45:14 +0100 |
commit | 7f88280929c350b087751e71e56e81b9b88d3495 (patch) | |
tree | 5e756d8d31e4d25b54249444b9726075a439c4c3 | |
parent | 243272c11178e68914d7cc2dcfdc28248edb2aa7 (diff) |
altair: make sure parse_vendor_pco_info() always returns an error
The parse_vendor_pco_info() method was returning NULL without error if
the pco info string was empty.
Under this situation, the code would have tried to add a NULL MMPco
into the pco_list list, which is not desired.
Avoid this, by making sure a NULL return always sets an error.
-rw-r--r-- | plugins/altair/mm-broadband-modem-altair-lte.c | 6 | ||||
-rw-r--r-- | plugins/altair/mm-modem-helpers-altair-lte.c | 6 |
2 files changed, 9 insertions, 3 deletions
diff --git a/plugins/altair/mm-broadband-modem-altair-lte.c b/plugins/altair/mm-broadband-modem-altair-lte.c index 9e555f5b..d26335f7 100644 --- a/plugins/altair/mm-broadband-modem-altair-lte.c +++ b/plugins/altair/mm-broadband-modem-altair-lte.c @@ -1105,9 +1105,13 @@ altair_pco_info_changed (MMPortSerialAt *port, pco_info = g_match_info_fetch (match_info, 0); + /* ignore if empty */ + if (!pco_info || !pco_info[0]) + return; + mm_obj_dbg (self, "parsing vendor PCO info: %s", pco_info); pco = mm_altair_parse_vendor_pco_info (pco_info, &error); - if (error) { + if (!pco) { mm_obj_warn (self, "error parsing vendor PCO info: %s", error->message); return; } diff --git a/plugins/altair/mm-modem-helpers-altair-lte.c b/plugins/altair/mm-modem-helpers-altair-lte.c index d1b2aa5c..278f31e8 100644 --- a/plugins/altair/mm-modem-helpers-altair-lte.c +++ b/plugins/altair/mm-modem-helpers-altair-lte.c @@ -140,9 +140,11 @@ mm_altair_parse_vendor_pco_info (const gchar *pco_info, GError **error) MMPco *pco = NULL; gint num_matches; - if (!pco_info[0]) - /* No APNs configured, all done */ + if (!pco_info || !pco_info[0]) { + g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_INVALID_ARGS, + "No PCO info given"); return NULL; + } /* Expected %PCOINFO response: * |