From ac243f94676695d88e861d225e98ec5bb3c2861e Mon Sep 17 00:00:00 2001 From: Carlo Lobrano Date: Fri, 8 Apr 2022 11:46:11 +0200 Subject: 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 --- src/mm-modem-helpers.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/mm-modem-helpers.c') diff --git a/src/mm-modem-helpers.c b/src/mm-modem-helpers.c index 72714ab9..5e58ba9d 100644 --- a/src/mm-modem-helpers.c +++ b/src/mm-modem-helpers.c @@ -5112,15 +5112,17 @@ mm_parse_cclk_response (const char *response, mm_network_timezone_set_offset (*tzp, tz * 15); } + ret = TRUE; + if (iso8601p) { /* 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); } - ret = TRUE; - out: g_match_info_free (match_info); g_regex_unref (r); -- cgit v1.2.3-70-g09d2