From 0b271a0731e616d76d38f294269fffb4409ad8d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Sat, 22 Jul 2006 17:01:12 +0000 Subject: [PATCH] gst/typefind/gsttypefindfunctions.c: Limit search for the first markup tag to the first few kB of the file. If we don... Original commit message from CVS: * gst/typefind/gsttypefindfunctions.c: (xml_check_first_element): Limit search for the first markup tag to the first few kB of the file. If we don't find one there, it's highly unlikely that this is an XML(-ish) file. --- ChangeLog | 7 +++++++ gst/typefind/gsttypefindfunctions.c | 7 ++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9b6c75b4ec..95c326b511 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2006-07-22 Tim-Philipp Müller + + * gst/typefind/gsttypefindfunctions.c: (xml_check_first_element): + Limit search for the first markup tag to the first few kB of + the file. If we don't find one there, it's highly unlikely that + this is an XML(-ish) file. + 2006-07-21 Andy Wingo * tests/check/pipelines/theoraenc.c (test_discontinuity): Similar diff --git a/gst/typefind/gsttypefindfunctions.c b/gst/typefind/gsttypefindfunctions.c index c8fd9d4e6a..3b305df775 100644 --- a/gst/typefind/gsttypefindfunctions.c +++ b/gst/typefind/gsttypefindfunctions.c @@ -225,9 +225,10 @@ xml_check_first_element (GstTypeFind * tf, const gchar * element, guint elen, data += 5; } - /* look for the first element, it has to be the requested element */ - while (data) { - while (*data != '<') { + /* look for the first element, it has to be the requested element. Bail + * out if it is not within the first 4kB. */ + while (data && (offset + pos) < 4096) { + while (*data != '<' && (offset + pos) < 4096) { XML_INC_BUFFER; }