From ce3af94a693aa05e90416649f832f36b62630c69 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 26 Apr 2017 07:19:44 +0100 Subject: [PATCH 1/2] mantis 6738: change parsing of the HTTP_CUSTOM_HEADER parameter and ignore entries in excess of 8 on the request --- .../Scripting/HttpRequest/ScriptsHttpRequests.cs | 12 ++++-------- .../Shared/Api/Implementation/LSL_Api.cs | 13 ++++++++++--- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs index 09891f7876..035097f8d2 100644 --- a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs +++ b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs @@ -223,20 +223,16 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest if (parms.Length - i < 2) break; - //Have we reached the end of the list of headers? - //End is marked by a string with a single digit. - //We already know we have at least one parameter - //so it is safe to do this check at top of loop. - if (Char.IsDigit(parms[i][0])) - break; - if (htc.HttpCustomHeaders == null) htc.HttpCustomHeaders = new List(); htc.HttpCustomHeaders.Add(parms[i]); htc.HttpCustomHeaders.Add(parms[i+1]); + int nexti = i + 2; + if (nexti >= parms.Length || Char.IsDigit(parms[nexti][0])) + break; - i += 2; + i = nexti; } break; diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 47c3cb89c6..2000c44628 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -13405,6 +13405,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api List param = new List(); bool ok; Int32 flag; + int nCustomHeaders = 0; for (int i = 0; i < parameters.Data.Length; i += 2) { @@ -13431,6 +13432,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api //Second Life documentation for llHTTPRequest. for (int count = 1; count <= 8; ++count) { + if(nCustomHeaders >= 8) + { + Error("llHTTPRequest", "Max number of custom headers is 8, excess ignored"); + break; + } + //Enough parameters remaining for (another) header? if (parameters.Data.Length - i < 2) { @@ -13445,15 +13452,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api param.Add(parameters.Data[i].ToString()); param.Add(parameters.Data[i+1].ToString()); + nCustomHeaders++; //Have we reached the end of the list of headers? //End is marked by a string with a single digit. - if (i+2 >= parameters.Data.Length || - Char.IsDigit(parameters.Data[i].ToString()[0])) + if (i + 2 >= parameters.Data.Length || + Char.IsDigit(parameters.Data[i + 2].ToString()[0])) { break; } - i += 2; } } From 1b8c71c965c82a79011290c2cfbcbc8eb1e409c4 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 26 Apr 2017 16:15:33 +0100 Subject: [PATCH 2/2] give more information on Fatal Error during region startup --- OpenSim/Framework/Servers/BaseOpenSimServer.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs index f761813560..62cd5439a6 100644 --- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs +++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs @@ -163,8 +163,7 @@ namespace OpenSim.Framework.Servers } catch(Exception e) { - m_log.FatalFormat("Fatal error: {0}", - (e.Message == null || e.Message == String.Empty) ? "Unknown reason":e.Message ); + m_log.Fatal("Fatal error: " + e.ToString()); Environment.Exit(1); }