diff options
author | Carlo Lobrano <c.lobrano@gmail.com> | 2022-04-08 11:46:11 +0200 |
---|---|---|
committer | Carlo Lobrano <c.lobrano@gmail.com> | 2022-04-08 15:41:49 +0200 |
commit | ac243f94676695d88e861d225e98ec5bb3c2861e (patch) | |
tree | 339f80e309a17e17e707d0716f2bf4e070fae2c1 /plugins/cinterion/mm-modem-helpers-cinterion.c | |
parent | 5c8c1136bd3bad2b542a0b3dc334dbd0686ba10d (diff) |
sms: prevent crash if date is out of range
g_date_time_new, and g_date_time_new_utc return NULL if inputs are out
of range, and currently mm_new_iso8601_time passes the GDateTime created
by those two functions to date_time_format_iso8601 without checking for
NULL values, causing a g_date_time_format_iso8601 crash if PDU data is
corrupted with wrong date.
To prevent this, mm_new_iso8601_time now can return NULL and set a new
GError if GDateTime created by g_date_time_new is NULL.
Fixes #546
Diffstat (limited to 'plugins/cinterion/mm-modem-helpers-cinterion.c')
-rw-r--r-- | plugins/cinterion/mm-modem-helpers-cinterion.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/plugins/cinterion/mm-modem-helpers-cinterion.c b/plugins/cinterion/mm-modem-helpers-cinterion.c index f8cec825..a75eb530 100644 --- a/plugins/cinterion/mm-modem-helpers-cinterion.c +++ b/plugins/cinterion/mm-modem-helpers-cinterion.c @@ -1201,6 +1201,7 @@ mm_cinterion_parse_ctzu_urc (GMatchInfo *match_info, MMNetworkTimezone **tzp, GError **error) { + gboolean ret = TRUE; guint year = 0, month = 0, day = 0, hour = 0, minute = 0, second = 0, dst = 0; gint tz = 0; @@ -1229,7 +1230,9 @@ mm_cinterion_parse_ctzu_urc (GMatchInfo *match_info, /* Return ISO-8601 format date/time string */ *iso8601p = mm_new_iso8601_time (year, month, day, hour, minute, second, - TRUE, tz * 15); + TRUE, tz * 15, + error); + ret = (*iso8601p != NULL); } if (tzp) { @@ -1245,7 +1248,7 @@ mm_cinterion_parse_ctzu_urc (GMatchInfo *match_info, if (tzp && mm_get_uint_from_match_info (match_info, 8, &dst)) mm_network_timezone_set_dst_offset (*tzp, dst * 60); - return TRUE; + return ret; } /*****************************************************************************/ |