mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-24 16:18:16 +00:00
gst/wavparse/gstwavparse.c: Don't try to read beyond the end of the file just because the header claims a bigger size...
Original commit message from CVS: * gst/wavparse/gstwavparse.c: (gst_wavparse_get_upstream_size), (gst_wavparse_stream_headers), (gst_wavparse_stream_data): Don't try to read beyond the end of the file just because the header claims a bigger size (like with truncated files).
This commit is contained in:
parent
abb13bdd24
commit
459333b3c0
3 changed files with 40 additions and 5 deletions
|
@ -1,3 +1,10 @@
|
|||
2006-03-23 Tim-Philipp Müller <tim at centricular dot net>
|
||||
|
||||
* gst/wavparse/gstwavparse.c: (gst_wavparse_get_upstream_size),
|
||||
(gst_wavparse_stream_headers), (gst_wavparse_stream_data):
|
||||
Don't try to read beyond the end of the file just because
|
||||
the header claims a bigger size (like with truncated files).
|
||||
|
||||
2006-03-23 Tim-Philipp Müller <tim at centricular dot net>
|
||||
|
||||
* gst/wavparse/gstwavparse.c: (gst_wavparse_perform_seek),
|
||||
|
|
2
common
2
common
|
@ -1 +1 @@
|
|||
Subproject commit 658b51189850df022f032a4310c4ad477a76465f
|
||||
Subproject commit 252846b570144570a0aee25b5adefbfac3f5d4eb
|
|
@ -868,6 +868,21 @@ no_format:
|
|||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_wavparse_get_upstream_size (GstWavParse * wav, gint64 * len)
|
||||
{
|
||||
gboolean res = FALSE;
|
||||
GstFormat fmt = GST_FORMAT_BYTES;
|
||||
GstPad *peer;
|
||||
|
||||
if ((peer = gst_pad_get_peer (wav->sinkpad))) {
|
||||
res = gst_pad_query_duration (peer, &fmt, len);
|
||||
gst_object_unref (peer);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static GstFlowReturn
|
||||
gst_wavparse_stream_headers (GstWavParse * wav)
|
||||
{
|
||||
|
@ -925,6 +940,11 @@ gst_wavparse_stream_headers (GstWavParse * wav)
|
|||
if (!caps)
|
||||
goto unknown_format;
|
||||
|
||||
GST_DEBUG_OBJECT (wav, "blockalign = %u", (guint) wav->blockalign);
|
||||
GST_DEBUG_OBJECT (wav, "width = %u", (guint) wav->width);
|
||||
GST_DEBUG_OBJECT (wav, "depth = %u", (guint) wav->depth);
|
||||
GST_DEBUG_OBJECT (wav, "bps = %u", (guint) wav->bps);
|
||||
|
||||
/* create pad later so we can sniff the first few bytes
|
||||
* of the real data and correct our caps if necessary */
|
||||
gst_caps_replace (&wav->caps, caps);
|
||||
|
@ -961,19 +981,27 @@ gst_wavparse_stream_headers (GstWavParse * wav)
|
|||
|
||||
switch (tag) {
|
||||
/* TODO : Implement the various cases */
|
||||
case GST_RIFF_TAG_data:
|
||||
case GST_RIFF_TAG_data:{
|
||||
gint64 upstream_size;
|
||||
|
||||
GST_DEBUG_OBJECT (wav, "Got 'data' TAG, size : %d", size);
|
||||
gotdata = TRUE;
|
||||
wav->offset += 8;
|
||||
wav->datastart = wav->offset;
|
||||
/* file might be truncated */
|
||||
if (gst_wavparse_get_upstream_size (wav, &upstream_size)) {
|
||||
size = MIN (size, (upstream_size - wav->datastart));
|
||||
}
|
||||
wav->datasize = size;
|
||||
wav->dataleft = size;
|
||||
wav->end_offset = size + wav->datastart;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
GST_DEBUG_OBJECT (wav, "Ignoring tag %" GST_FOURCC_FORMAT,
|
||||
GST_FOURCC_ARGS (tag));
|
||||
wav->offset += 8 + ((size + 1) & ~1);
|
||||
break;
|
||||
}
|
||||
gst_buffer_unref (buf);
|
||||
}
|
||||
|
@ -1145,7 +1173,7 @@ gst_wavparse_stream_data (GstWavParse * wav, gboolean first)
|
|||
wav->offset, wav->end_offset);
|
||||
|
||||
/* Get the next n bytes and output them */
|
||||
if (wav->dataleft == 0)
|
||||
if (wav->dataleft == 0 || wav->dataleft < wav->blockalign)
|
||||
goto found_eos;
|
||||
|
||||
/* scale the amount of data by the segment rate so we get equal
|
||||
|
@ -1228,8 +1256,8 @@ found_eos:
|
|||
}
|
||||
pull_error:
|
||||
{
|
||||
GST_DEBUG_OBJECT (wav, "Error getting %ldd bytes from the sinkpad!",
|
||||
desired);
|
||||
GST_DEBUG_OBJECT (wav, "Error getting %" G_GINT64_FORMAT " bytes from the "
|
||||
"sinkpad (dataleft = %" G_GINT64_FORMAT ")", desired, wav->dataleft);
|
||||
return res;
|
||||
}
|
||||
push_error:
|
||||
|
|
Loading…
Reference in a new issue