From 7adc2212c7e92a46483934e060bb14194f3b0e38 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Mon, 10 Sep 2007 04:30:11 +0000 Subject: * Fixed: Accessing xmlrpc with invalid xml data would crash the sim. * Ignored some bins and gens --- OpenSim/Framework/Servers/BaseHttpServer.cs | 48 +++++++++++++++++++---------- 1 file changed, 31 insertions(+), 17 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/Servers/BaseHttpServer.cs b/OpenSim/Framework/Servers/BaseHttpServer.cs index 4eb776e..c3cf5e1 100644 --- a/OpenSim/Framework/Servers/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/BaseHttpServer.cs @@ -35,6 +35,7 @@ using System.Text.RegularExpressions; using System.Threading; using Nwc.XmlRpc; using OpenSim.Framework.Console; +using System.Xml; namespace OpenSim.Framework.Servers { @@ -153,31 +154,44 @@ namespace OpenSim.Framework.Servers reader.Close(); requestStream.Close(); - XmlRpcRequest xmlRprcRequest = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(requestBody); + string responseString = String.Empty; + XmlRpcRequest xmlRprcRequest = null; - string methodName = xmlRprcRequest.MethodName; - - XmlRpcResponse xmlRpcResponse; - - XmlRpcMethod method; - if (this.m_rpcHandlers.TryGetValue(methodName, out method)) + try { - xmlRpcResponse = method(xmlRprcRequest); + xmlRprcRequest = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(requestBody); } - else + catch ( XmlException e ) + { + responseString = String.Format( "XmlException:\n{0}",e.Message ); + } + + if (xmlRprcRequest != null) { - xmlRpcResponse = new XmlRpcResponse(); - Hashtable unknownMethodError = new Hashtable(); - unknownMethodError["reason"] = "XmlRequest"; ; - unknownMethodError["message"] = "Unknown Rpc Request ["+methodName+"]"; - unknownMethodError["login"] = "false"; - xmlRpcResponse.Value = unknownMethodError; + string methodName = xmlRprcRequest.MethodName; + + XmlRpcResponse xmlRpcResponse; + + XmlRpcMethod method; + if (this.m_rpcHandlers.TryGetValue(methodName, out method)) + { + xmlRpcResponse = method(xmlRprcRequest); + } + else + { + xmlRpcResponse = new XmlRpcResponse(); + Hashtable unknownMethodError = new Hashtable(); + unknownMethodError["reason"] = "XmlRequest"; ; + unknownMethodError["message"] = "Unknown Rpc Request [" + methodName + "]"; + unknownMethodError["login"] = "false"; + xmlRpcResponse.Value = unknownMethodError; + } + + responseString = XmlRpcResponseSerializer.Singleton.Serialize(xmlRpcResponse); } response.AddHeader("Content-type", "text/xml"); - string responseString = XmlRpcResponseSerializer.Singleton.Serialize(xmlRpcResponse); - byte[] buffer = Encoding.UTF8.GetBytes(responseString); response.SendChunked = false; -- cgit v1.1