From 6846810f5072431dace6f3064e6e8353cc4d174f Mon Sep 17 00:00:00 2001 From: Ilie Halip Date: Sat, 18 Mar 2023 11:54:15 +0200 Subject: [PATCH] typefindfunctions: Increase xml typefinder closing brace limit If the first XML element in a DASH manifest has its closing brance beyond the first 512 bytes (because of, e.g. lots of attributes), the MPD typefinder fails. Try to read a larger block, and then smaller blocks until 512 bytes. Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/2385 Part-of: --- .../gst/typefind/gsttypefindfunctions.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/subprojects/gst-plugins-base/gst/typefind/gsttypefindfunctions.c b/subprojects/gst-plugins-base/gst/typefind/gsttypefindfunctions.c index 3f595b2567..7fd39016cd 100644 --- a/subprojects/gst-plugins-base/gst/typefind/gsttypefindfunctions.c +++ b/subprojects/gst-plugins-base/gst/typefind/gsttypefindfunctions.c @@ -660,15 +660,17 @@ xml_check_first_element (GstTypeFind * tf, const gchar * element, guint elen, length = gst_type_find_get_length (tf); - /* try a default that should be enough */ - if (length == 0) - length = 512; - else if (length < 32) + if (length == 0) { + length = 4096; + while (!(data = gst_type_find_peek (tf, 0, length)) && length >= 512) + length /= 2; + } else if (length < 32) { return FALSE; - else /* the first few bytes should be enough */ + } else { /* the first few bytes should be enough */ length = MIN (4096, length); + data = gst_type_find_peek (tf, 0, length); + } - data = gst_type_find_peek (tf, 0, length); if (!data) return FALSE;