mpdparser: forbid negative values for duration

https://bugzilla.gnome.org/show_bug.cgi?id=752492
This commit is contained in:
Vincent Penquerc'h 2015-09-08 14:00:54 +01:00
parent c763d1e8fd
commit 54d93f597d

View file

@ -901,8 +901,9 @@ convert_to_millisecs (gint decimals, gint pos)
} }
static gboolean static gboolean
gst_mpdparser_get_xml_prop_duration (xmlNode * a_node, gst_mpdparser_get_xml_prop_duration_inner (xmlNode * a_node,
const gchar * property_name, gint64 default_value, gint64 * property_value) const gchar * property_name, gint64 default_value, gint64 * property_value,
gboolean allow_negative)
{ {
xmlChar *prop_string; xmlChar *prop_string;
gchar *str; gchar *str;
@ -927,6 +928,10 @@ gst_mpdparser_get_xml_prop_duration (xmlNode * a_node,
goto error; goto error;
} }
GST_TRACE ("found - sign at the beginning"); GST_TRACE ("found - sign at the beginning");
if (!allow_negative) {
GST_WARNING ("sign \"-\" not allowed for property '%s'", property_name);
goto error;
}
sign = -1; sign = -1;
str++; str++;
len--; len--;
@ -1043,6 +1048,22 @@ error:
return FALSE; return FALSE;
} }
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 static gboolean
gst_mpdparser_get_xml_node_content (xmlNode * a_node, gchar ** content) gst_mpdparser_get_xml_node_content (xmlNode * a_node, gchar ** content)
{ {
@ -2080,8 +2101,8 @@ gst_mpdparser_parse_root_node (GstMPDNode ** pointer, xmlNode * a_node)
&new_mpd->minBufferTime); &new_mpd->minBufferTime);
gst_mpdparser_get_xml_prop_duration (a_node, "timeShiftBufferDepth", -1, gst_mpdparser_get_xml_prop_duration (a_node, "timeShiftBufferDepth", -1,
&new_mpd->timeShiftBufferDepth); &new_mpd->timeShiftBufferDepth);
gst_mpdparser_get_xml_prop_duration (a_node, "suggestedPresentationDelay", -1, gst_mpdparser_get_xml_prop_duration_unsigned (a_node,
&new_mpd->suggestedPresentationDelay); "suggestedPresentationDelay", -1, &new_mpd->suggestedPresentationDelay);
gst_mpdparser_get_xml_prop_duration (a_node, "maxSegmentDuration", -1, gst_mpdparser_get_xml_prop_duration (a_node, "maxSegmentDuration", -1,
&new_mpd->maxSegmentDuration); &new_mpd->maxSegmentDuration);
gst_mpdparser_get_xml_prop_duration (a_node, "maxSubsegmentDuration", -1, gst_mpdparser_get_xml_prop_duration (a_node, "maxSubsegmentDuration", -1,