From eae0c80f165b4b93dea27c49afad098ca2c23643 Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Fri, 18 Nov 2005 16:14:00 +0000 Subject: [PATCH] gst/iec958/ac3iec.c: Remove some setcaps brokenness. Original commit message from CVS: * gst/iec958/ac3iec.c: (ac3iec_init), (ac3iec_chain_dvd): Remove some setcaps brokenness. Don't crash on bad input. --- ChangeLog | 6 ++++++ common | 2 +- gst/iec958/ac3iec.c | 37 +++++++++++++++---------------------- 3 files changed, 22 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index b148191..df96d13 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-11-18 Michael Smith + + * gst/iec958/ac3iec.c: (ac3iec_init), (ac3iec_chain_dvd): + Remove some setcaps brokenness. + Don't crash on bad input. + 2005-11-15 Johan Dahlin * ext/mad/gstid3tag.c (gst_mad_id3_to_tag_list): unset GValues after diff --git a/common b/common index 657b549..ea14091 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit 657b549dfb640a76f3d7ab7676e453c801a83dca +Subproject commit ea1409191cc1e71273b2dbdd94e7ab5fc5a60a51 diff --git a/gst/iec958/ac3iec.c b/gst/iec958/ac3iec.c index 2a59c20..0c6e543 100644 --- a/gst/iec958/ac3iec.c +++ b/gst/iec958/ac3iec.c @@ -86,7 +86,6 @@ static void ac3iec_get_property (GObject * object, static GstFlowReturn ac3iec_chain_dvd (GstPad * pad, GstBuffer * buf); static GstFlowReturn ac3iec_chain_raw (GstPad * pad, GstBuffer * buf); -static gboolean ac3iec_setcaps (GstPad * pad, GstCaps * caps); static GstStateChangeReturn ac3iec_change_state (GstElement * element, GstStateChange transition); @@ -161,15 +160,16 @@ ac3iec_init (AC3IEC * ac3iec) ac3iec->sink = gst_pad_new_from_template (gst_static_pad_template_get (&ac3iec_sink_template), "sink"); - gst_element_add_pad (GST_ELEMENT (ac3iec), ac3iec->sink); - gst_pad_set_setcaps_function (ac3iec->sink, ac3iec_setcaps); gst_pad_set_chain_function (ac3iec->sink, ac3iec_chain_dvd); + gst_element_add_pad (GST_ELEMENT (ac3iec), ac3iec->sink); ac3iec->src = gst_pad_new_from_template (gst_static_pad_template_get (&ac3iec_src_template), "src"); + gst_pad_use_fixed_caps (ac3iec->src); gst_element_add_pad (GST_ELEMENT (ac3iec), ac3iec->src); + ac3iec->cur_ts = GST_CLOCK_TIME_NONE; ac3iec->padder = g_malloc (sizeof (ac3_padder)); @@ -184,25 +184,6 @@ ac3iec_finalize (GObject * object) g_free (ac3iec->padder); } -static gboolean -ac3iec_setcaps (GstPad * pad, GstCaps * caps) -{ - AC3IEC *ac3iec = AC3IEC (gst_pad_get_parent (pad)); - gboolean res = TRUE; - GstCaps *src_caps; - - src_caps = gst_caps_new_simple ("audio/x-iec958", NULL); - - if (!gst_pad_set_caps (ac3iec->src, src_caps)) { - res = FALSE; - } - - gst_caps_unref (src_caps); - gst_object_unref (ac3iec); - - return res; -} - static void ac3iec_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) @@ -260,6 +241,12 @@ ac3iec_chain_dvd (GstPad * pad, GstBuffer * buf) /* Length of data before first_access */ len = first_access - 1; + /* Ensure we don't crash if fed totally invalid data */ + if (offset + len > size) { + ret = GST_FLOW_ERROR; + goto done; + } + if (len > 0) { subbuf = gst_buffer_create_sub (buf, offset, len); GST_BUFFER_TIMESTAMP (subbuf) = GST_CLOCK_TIME_NONE; @@ -276,6 +263,12 @@ ac3iec_chain_dvd (GstPad * pad, GstBuffer * buf) ret = ac3iec_chain_raw (pad, subbuf); } else { + /* Ensure we don't crash if fed totally invalid data */ + if (size < 2) { + ret = GST_FLOW_ERROR; + goto done; + } + /* No first_access, so no timestamp */ subbuf = gst_buffer_create_sub (buf, offset, size - offset); GST_BUFFER_TIMESTAMP (subbuf) = GST_CLOCK_TIME_NONE; -- 2.7.4