diff --git a/gst-libs/gst/riff/riff-read.c b/gst-libs/gst/riff/riff-read.c index b39ba2c4c8..fe0aa74e86 100644 --- a/gst-libs/gst/riff/riff-read.c +++ b/gst-libs/gst/riff/riff-read.c @@ -153,6 +153,10 @@ gst_riff_parse_chunk (GstElement * element, GstBuffer * buf, GST_DEBUG_OBJECT (element, "fourcc=%" GST_FOURCC_FORMAT ", size=%u", GST_FOURCC_ARGS (fourcc), size); + /* be paranoid: size may be nonsensical value here, such as (guint) -1 */ + if (G_UNLIKELY (size > G_MAXINT)) + goto bogus_size; + if (bufsize < size + 8 + offset) { GST_DEBUG_OBJECT (element, "Needed chunk data (%d) is more than available (%d), shortcutting", @@ -183,6 +187,11 @@ too_small: offset, bufsize, 8); return FALSE; } +bogus_size: + { + GST_ERROR_OBJECT (element, "Broken file: bogus chunk size %u", size); + return FALSE; + } } /**