diff --git a/gst/gstdatetime.c b/gst/gstdatetime.c index 8c0eda5..b947f4f 100644 --- a/gst/gstdatetime.c +++ b/gst/gstdatetime.c @@ -853,7 +853,7 @@ gst_date_time_new_from_iso8601_string (const gchar * string) else if (neg_pos) pos = neg_pos + 1; - if (pos) { + if (pos && strlen (pos) >= 3) { gint ret_tz; if (pos[2] == ':') ret_tz = sscanf (pos, "%d:%d", &gmt_offset_hour, &gmt_offset_min); diff --git a/tests/check/gst/gstdatetime.c b/tests/check/gst/gstdatetime.c index eb637c4..29f42fb 100644 --- a/tests/check/gst/gstdatetime.c +++ b/tests/check/gst/gstdatetime.c @@ -649,6 +649,14 @@ GST_START_TEST (test_GstDateTime_to_g_date_time) fail_unless (g_date_time_compare (gdt1, gdt2) == 0); + /* some bogus ones, make copy to detect out of bound read in valgrind/asan */ + { + gchar *s = g_strdup ("0002000000T00000:00+0"); + dt = gst_date_time_new_from_iso8601_string (s); + gst_date_time_unref (dt); + g_free (s); + } + g_date_time_unref (gdt1); g_date_time_unref (gdt2); gst_date_time_unref (dt);