From 90b7c137b6d192fff3b357714844ee7a02467e11 Mon Sep 17 00:00:00 2001 From: Florin Apostol Date: Mon, 20 Jul 2015 10:50:44 +0100 Subject: [PATCH] dahdemux: avoid overflows in computation of segment start time and duration Used gst_util_uint64_scale to avoid overflows when segment start time or duration is computed. https://bugzilla.gnome.org/show_bug.cgi?id=752620 --- ext/dash/gstmpdparser.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/ext/dash/gstmpdparser.c b/ext/dash/gstmpdparser.c index b967ca87bd..84c3c6347a 100644 --- a/ext/dash/gstmpdparser.c +++ b/ext/dash/gstmpdparser.c @@ -2807,6 +2807,7 @@ gst_mpd_client_get_segment_duration (GstMpdClient * client, if (scale_dur) *scale_dur = duration; } else { + /* duration is guint so this cannot overflow */ duration = base->duration * GST_SECOND; if (scale_dur) *scale_dur = duration; @@ -3127,14 +3128,13 @@ gst_mpd_client_setup_representation (GstMpdClient * client, S = (GstSNode *) list->data; GST_LOG ("Processing S node: d=%" G_GUINT64_FORMAT " r=%d t=%" G_GUINT64_FORMAT, S->d, S->r, S->t); - duration = S->d * GST_SECOND; timescale = stream->cur_segment_list->MultSegBaseType->SegBaseType->timescale; - duration /= timescale; + duration = gst_util_uint64_scale (S->d, GST_SECOND, timescale); + if (S->t > 0) { start = S->t; - start_time = S->t * GST_SECOND; - start_time /= timescale; + start_time = gst_util_uint64_scale (S->t, GST_SECOND, timescale); start_time += PeriodStart; } @@ -3217,13 +3217,11 @@ gst_mpd_client_setup_representation (GstMpdClient * client, S = (GstSNode *) list->data; GST_LOG ("Processing S node: d=%" G_GUINT64_FORMAT " r=%u t=%" G_GUINT64_FORMAT, S->d, S->r, S->t); - duration = S->d * GST_SECOND; timescale = mult_seg->SegBaseType->timescale; - duration /= timescale; + duration = gst_util_uint64_scale (S->d, GST_SECOND, timescale); if (S->t > 0) { start = S->t; - start_time = S->t * GST_SECOND; - start_time /= timescale; + start_time = gst_util_uint64_scale (S->t, GST_SECOND, timescale); start_time += PeriodStart; }