Don't allow oversized search reply packets

avinationmerge
Melanie Thielker 2010-08-21 17:48:49 +02:00
parent 3ffdadef70
commit 8613336674
1 changed files with 42 additions and 17 deletions

View File

@ -2734,31 +2734,56 @@ namespace OpenSim.Region.ClientStack.LindenUDP
packet.QueryData = new DirPlacesReplyPacket.QueryDataBlock[1];
packet.QueryData[0] = new DirPlacesReplyPacket.QueryDataBlock();
packet.QueryReplies =
new DirPlacesReplyPacket.QueryRepliesBlock[data.Length];
packet.AgentData.AgentID = AgentId;
packet.StatusData = new DirPlacesReplyPacket.StatusDataBlock[
data.Length];
packet.QueryData[0].QueryID = queryID;
DirPlacesReplyPacket.QueryRepliesBlock[] replies =
new DirPlacesReplyPacket.QueryRepliesBlock[0];
DirPlacesReplyPacket.StatusDataBlock[] status =
new DirPlacesReplyPacket.StatusDataBlock[0];
int i = 0;
foreach (DirPlacesReplyData d in data)
{
int idx = replies.Length;
Array.Resize(ref replies, idx + 1);
Array.Resize(ref status, idx + 1);
replies[idx] = new DirPlacesReplyPacket.QueryRepliesBlock();
status[idx] = new DirPlacesReplyPacket.StatusDataBlock();
replies[idx].ParcelID = d.parcelID;
replies[idx].Name = Utils.StringToBytes(d.name);
replies[idx].ForSale = d.forSale;
replies[idx].Auction = d.auction;
replies[idx].Dwell = d.dwell;
status[idx].Status = d.Status;
packet.QueryReplies = replies;
packet.StatusData = status;
if (packet.Length >= 1000)
{
OutPacket(packet, ThrottleOutPacketType.Task);
packet = (DirPlacesReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirPlacesReply);
packet.AgentData = new DirPlacesReplyPacket.AgentDataBlock();
packet.QueryData = new DirPlacesReplyPacket.QueryDataBlock[1];
packet.QueryData[0] = new DirPlacesReplyPacket.QueryDataBlock();
packet.AgentData.AgentID = AgentId;
packet.QueryData[0].QueryID = queryID;
int i = 0;
foreach (DirPlacesReplyData d in data)
{
packet.QueryReplies[i] =
new DirPlacesReplyPacket.QueryRepliesBlock();
packet.StatusData[i] = new DirPlacesReplyPacket.StatusDataBlock();
packet.QueryReplies[i].ParcelID = d.parcelID;
packet.QueryReplies[i].Name = Utils.StringToBytes(d.name);
packet.QueryReplies[i].ForSale = d.forSale;
packet.QueryReplies[i].Auction = d.auction;
packet.QueryReplies[i].Dwell = d.dwell;
packet.StatusData[i].Status = d.Status;
i++;
replies = new DirPlacesReplyPacket.QueryRepliesBlock[0];
status = new DirPlacesReplyPacket.StatusDataBlock[0];
}
}
if (replies.Length > 0)
OutPacket(packet, ThrottleOutPacketType.Task);
}