summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Penquerc'h <vincent.penquerch@collabora.co.uk>2011-08-16 10:24:37 +0100
committerTim-Philipp Müller <tim.muller@collabora.co.uk>2011-08-16 23:25:38 +0100
commit0381919e83eb891d2a76eda1dfab15b7e641fca9 (patch)
tree0f2f529fb52291a4db4957b2c8672eaf55fb169c
parent76c0f9bfe77af7dcf7ae60753260925ee8264253 (diff)
downloadgstreamer-plugins-bad-0381919e83eb891d2a76eda1dfab15b7e641fca9.tar.gz
aiffmux: drop data after 4ish GB and moan
https://bugzilla.gnome.org/show_bug.cgi?id=654278
-rw-r--r--gst/aiff/aiffmux.c26
-rw-r--r--gst/aiff/aiffmux.h1
2 files changed, 27 insertions, 0 deletions
diff --git a/gst/aiff/aiffmux.c b/gst/aiff/aiffmux.c
index e9f7aa5eb..a2d99f587 100644
--- a/gst/aiff/aiffmux.c
+++ b/gst/aiff/aiffmux.c
@@ -130,6 +130,7 @@ gst_aiff_mux_change_state (GstElement * element, GstStateChange transition)
aiffmux->length = 0;
aiffmux->rate = 0.0;
aiffmux->sent_header = FALSE;
+ aiffmux->overflow = FALSE;
break;
default:
break;
@@ -296,12 +297,16 @@ gst_aiff_mux_chain (GstPad * pad, GstBuffer * buf)
{
GstAiffMux *aiffmux = GST_AIFF_MUX (GST_PAD_PARENT (pad));
GstFlowReturn flow = GST_FLOW_OK;
+ guint64 cur_size;
if (!aiffmux->channels) {
gst_buffer_unref (buf);
return GST_FLOW_NOT_NEGOTIATED;
}
+ if (G_UNLIKELY (aiffmux->overflow))
+ goto overflow;
+
if (!aiffmux->sent_header) {
/* use bogus size initially, we'll write the real
* header when we get EOS and know the exact length */
@@ -316,6 +321,20 @@ gst_aiff_mux_chain (GstPad * pad, GstBuffer * buf)
aiffmux->sent_header = TRUE;
}
+ /* AIFF has an audio data size limit of slightly under 4 GB.
+ A value of audiosize + AIFF_HEADER_LEN - 8 is written, so
+ I'll error out if writing data that makes this overflow. */
+ cur_size = aiffmux->length + AIFF_HEADER_LEN - 8;
+ if (G_UNLIKELY (cur_size + GST_BUFFER_SIZE (buf) >= G_MAXUINT32)) {
+ GST_ERROR_OBJECT (aiffmux, "AIFF only supports about 4 GB worth of "
+ "audio data, dropping any further data on the floor");
+ GST_ELEMENT_WARNING (aiffmux, STREAM, MUX, ("AIFF has a 4GB size limit"),
+ ("AIFF only supports about 4 GB worth of audio data, "
+ "dropping any further data on the floor"));
+ aiffmux->overflow = TRUE;
+ goto overflow;
+ }
+
GST_LOG_OBJECT (aiffmux, "pushing %u bytes raw audio, ts=%" GST_TIME_FORMAT,
GST_BUFFER_SIZE (buf), GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)));
@@ -330,6 +349,13 @@ gst_aiff_mux_chain (GstPad * pad, GstBuffer * buf)
flow = gst_pad_push (aiffmux->srcpad, buf);
return flow;
+
+overflow:
+ {
+ GST_WARNING_OBJECT (aiffmux, "output file too large, dropping buffer");
+ gst_buffer_unref (buf);
+ return GST_FLOW_OK;
+ }
}
static gboolean
diff --git a/gst/aiff/aiffmux.h b/gst/aiff/aiffmux.h
index 73c1d89d3..9c0954f58 100644
--- a/gst/aiff/aiffmux.h
+++ b/gst/aiff/aiffmux.h
@@ -81,6 +81,7 @@ struct _GstAiffMux
gdouble rate;
gboolean sent_header;
+ gboolean overflow;
};
struct _GstAiffMuxClass