From 4ad1468165b80f67439399e36688d36944996312 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Sun, 5 Jul 2015 16:05:01 +0300 Subject: Better handling of invalid XML: a) prevent infinite loop on EOF; b) better logging If the XML was truncated for some reason then ExecuteReadProcessors() would get into an infinite loop, using high CPU. Now it detects EOF (and several other error cases) and aborts. The rest of the changes just improve logging of XML in case of errors, so that we can see what the bad XML is. --- OpenSim/Framework/Util.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'OpenSim/Framework/Util.cs') diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 875f4ad..a5f798d 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs @@ -2910,6 +2910,16 @@ namespace OpenSim.Framework return name; } + + public static void LogFailedXML(string message, string xml) + { + int length = xml.Length; + if (length > 2000) + xml = xml.Substring(0, 2000) + "..."; + + m_log.ErrorFormat("{0} Failed XML ({1} bytes) = {2}", message, length, xml); + } + } public class DoubleQueue where T:class -- cgit v1.1