Skip to content
Snippets Groups Projects
Commit eae0c80f authored by Michael Smith's avatar Michael Smith
Browse files

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.
parent d62642b8
No related branches found
No related tags found
No related merge requests found
2005-11-18 Michael Smith <msmith@fluendo.com>
* gst/iec958/ac3iec.c: (ac3iec_init), (ac3iec_chain_dvd):
Remove some setcaps brokenness.
Don't crash on bad input.
2005-11-15 Johan Dahlin <johan@gnome.org> 2005-11-15 Johan Dahlin <johan@gnome.org>
* ext/mad/gstid3tag.c (gst_mad_id3_to_tag_list): unset GValues after * ext/mad/gstid3tag.c (gst_mad_id3_to_tag_list): unset GValues after
......
common @ ea140919
Subproject commit 657b549dfb640a76f3d7ab7676e453c801a83dca Subproject commit ea1409191cc1e71273b2dbdd94e7ab5fc5a60a51
...@@ -86,7 +86,6 @@ static void ac3iec_get_property (GObject * object, ...@@ -86,7 +86,6 @@ static void ac3iec_get_property (GObject * object,
static GstFlowReturn ac3iec_chain_dvd (GstPad * pad, GstBuffer * buf); static GstFlowReturn ac3iec_chain_dvd (GstPad * pad, GstBuffer * buf);
static GstFlowReturn ac3iec_chain_raw (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, static GstStateChangeReturn ac3iec_change_state (GstElement * element,
GstStateChange transition); GstStateChange transition);
...@@ -161,15 +160,16 @@ ac3iec_init (AC3IEC * ac3iec) ...@@ -161,15 +160,16 @@ ac3iec_init (AC3IEC * ac3iec)
ac3iec->sink = ac3iec->sink =
gst_pad_new_from_template (gst_static_pad_template_get gst_pad_new_from_template (gst_static_pad_template_get
(&ac3iec_sink_template), "sink"); (&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_pad_set_chain_function (ac3iec->sink, ac3iec_chain_dvd);
gst_element_add_pad (GST_ELEMENT (ac3iec), ac3iec->sink);
ac3iec->src = ac3iec->src =
gst_pad_new_from_template (gst_static_pad_template_get gst_pad_new_from_template (gst_static_pad_template_get
(&ac3iec_src_template), "src"); (&ac3iec_src_template), "src");
gst_pad_use_fixed_caps (ac3iec->src);
gst_element_add_pad (GST_ELEMENT (ac3iec), ac3iec->src); gst_element_add_pad (GST_ELEMENT (ac3iec), ac3iec->src);
ac3iec->cur_ts = GST_CLOCK_TIME_NONE; ac3iec->cur_ts = GST_CLOCK_TIME_NONE;
ac3iec->padder = g_malloc (sizeof (ac3_padder)); ac3iec->padder = g_malloc (sizeof (ac3_padder));
...@@ -184,25 +184,6 @@ ac3iec_finalize (GObject * object) ...@@ -184,25 +184,6 @@ ac3iec_finalize (GObject * object)
g_free (ac3iec->padder); 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 static void
ac3iec_set_property (GObject * object, guint prop_id, ac3iec_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec) const GValue * value, GParamSpec * pspec)
...@@ -260,6 +241,12 @@ ac3iec_chain_dvd (GstPad * pad, GstBuffer * buf) ...@@ -260,6 +241,12 @@ ac3iec_chain_dvd (GstPad * pad, GstBuffer * buf)
/* Length of data before first_access */ /* Length of data before first_access */
len = first_access - 1; 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) { if (len > 0) {
subbuf = gst_buffer_create_sub (buf, offset, len); subbuf = gst_buffer_create_sub (buf, offset, len);
GST_BUFFER_TIMESTAMP (subbuf) = GST_CLOCK_TIME_NONE; GST_BUFFER_TIMESTAMP (subbuf) = GST_CLOCK_TIME_NONE;
...@@ -276,6 +263,12 @@ ac3iec_chain_dvd (GstPad * pad, GstBuffer * buf) ...@@ -276,6 +263,12 @@ ac3iec_chain_dvd (GstPad * pad, GstBuffer * buf)
ret = ac3iec_chain_raw (pad, subbuf); ret = ac3iec_chain_raw (pad, subbuf);
} else { } 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 */ /* No first_access, so no timestamp */
subbuf = gst_buffer_create_sub (buf, offset, size - offset); subbuf = gst_buffer_create_sub (buf, offset, size - offset);
GST_BUFFER_TIMESTAMP (subbuf) = GST_CLOCK_TIME_NONE; GST_BUFFER_TIMESTAMP (subbuf) = GST_CLOCK_TIME_NONE;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment