mpdparser: forbid negative values for duration
authorVincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Tue, 8 Sep 2015 13:00:54 +0000 (14:00 +0100)
committerVincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Wed, 28 Oct 2015 15:43:00 +0000 (15:43 +0000)
https://bugzilla.gnome.org/show_bug.cgi?id=752492

ext/dash/gstmpdparser.c

index 059f1ea..3b153f7 100644 (file)
@@ -901,8 +901,9 @@ convert_to_millisecs (gint decimals, gint pos)
 }
 
 static gboolean
-gst_mpdparser_get_xml_prop_duration (xmlNode * a_node,
-    const gchar * property_name, gint64 default_value, gint64 * property_value)
+gst_mpdparser_get_xml_prop_duration_inner (xmlNode * a_node,
+    const gchar * property_name, gint64 default_value, gint64 * property_value,
+    gboolean allow_negative)
 {
   xmlChar *prop_string;
   gchar *str;
@@ -927,6 +928,10 @@ gst_mpdparser_get_xml_prop_duration (xmlNode * a_node,
         goto error;
       }
       GST_TRACE ("found - sign at the beginning");
+      if (!allow_negative) {
+        GST_WARNING ("sign \"-\" not allowed for property '%s'", property_name);
+        goto error;
+      }
       sign = -1;
       str++;
       len--;
@@ -1044,6 +1049,22 @@ error:
 }
 
 static gboolean
+gst_mpdparser_get_xml_prop_duration (xmlNode * a_node,
+    const gchar * property_name, gint64 default_value, gint64 * property_value)
+{
+  return gst_mpdparser_get_xml_prop_duration_inner (a_node, property_name,
+      default_value, property_value, TRUE);
+}
+
+static gboolean
+gst_mpdparser_get_xml_prop_duration_unsigned (xmlNode * a_node,
+    const gchar * property_name, gint64 default_value, gint64 * property_value)
+{
+  return gst_mpdparser_get_xml_prop_duration_inner (a_node, property_name,
+      default_value, property_value, FALSE);
+}
+
+static gboolean
 gst_mpdparser_get_xml_node_content (xmlNode * a_node, gchar ** content)
 {
   xmlChar *node_content = NULL;
@@ -2080,8 +2101,8 @@ gst_mpdparser_parse_root_node (GstMPDNode ** pointer, xmlNode * a_node)
       &new_mpd->minBufferTime);
   gst_mpdparser_get_xml_prop_duration (a_node, "timeShiftBufferDepth", -1,
       &new_mpd->timeShiftBufferDepth);
-  gst_mpdparser_get_xml_prop_duration (a_node, "suggestedPresentationDelay", -1,
-      &new_mpd->suggestedPresentationDelay);
+  gst_mpdparser_get_xml_prop_duration_unsigned (a_node,
+      "suggestedPresentationDelay", -1, &new_mpd->suggestedPresentationDelay);
   gst_mpdparser_get_xml_prop_duration (a_node, "maxSegmentDuration", -1,
       &new_mpd->maxSegmentDuration);
   gst_mpdparser_get_xml_prop_duration (a_node, "maxSubsegmentDuration", -1,