From aab1601642ef6c1b028fc3160e809732ab4d1769 Mon Sep 17 00:00:00 2001 From: idb Date: Sat, 7 Mar 2009 14:16:26 +0000 Subject: Limit the message length from llInstantMessage to 1024 characters http://wiki.secondlife.com/wiki/LlInstantMessage Also truncate messages that may exceed the limit set by the packet size. The limit in OpenMetaverse is 1100 bytes including a zero byte terminator. Fixes Mantis #3244 --- OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs | 7 ++++++- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 6e1bd82..ac427d7 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -1206,7 +1206,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP msg.MessageBlock.RegionID = UUID.Zero; msg.MessageBlock.Timestamp = timeStamp; msg.MessageBlock.ToAgentID = toAgent; - msg.MessageBlock.Message = Utils.StringToBytes(message); + // Cap the message length at 1099. There is a limit in ImprovedInstantMessagePacket + // the limit is 1100 but a 0 byte gets added to mark the end of the string + if (message != null && message.Length > 1099) + msg.MessageBlock.Message = Utils.StringToBytes(message.Substring(0, 1099)); + else + msg.MessageBlock.Message = Utils.StringToBytes(message); msg.MessageBlock.BinaryBucket = binaryBucket; if (message.StartsWith("[grouptest]")) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 6bb0fe9..69d9c38 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -2717,7 +2717,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api //{ // msg.fromAgentName = "(hippos)";// Added for posterity. This means that we can't figure out who sent it //} - msg.message = message; + // Cap the message length at 1024. + if (message != null && message.Length > 1024) + msg.message = message.Substring(0, 1024); + else + msg.message = message; msg.dialog = (byte)19; // messgage from script ??? // dialog; msg.fromGroup = false;// fromGroup; msg.offline = (byte)0; //offline; -- cgit v1.1