Prevent a buffer overflow in asset receiving
parent
5cbf7b3997
commit
6faa7fc7f9
|
@ -100,18 +100,27 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
|
||||||
|
|
||||||
if (XferID == xferID)
|
if (XferID == xferID)
|
||||||
{
|
{
|
||||||
if (m_asset.Data.Length > 1)
|
lock (this)
|
||||||
{
|
{
|
||||||
byte[] destinationArray = new byte[m_asset.Data.Length + data.Length];
|
int assetLength = m_asset.Data.Length;
|
||||||
Array.Copy(m_asset.Data, 0, destinationArray, 0, m_asset.Data.Length);
|
int dataLength = data.Length;
|
||||||
Array.Copy(data, 0, destinationArray, m_asset.Data.Length, data.Length);
|
|
||||||
m_asset.Data = destinationArray;
|
if (m_asset.Data.Length > 1)
|
||||||
}
|
{
|
||||||
else
|
byte[] destinationArray = new byte[assetLength + dataLength];
|
||||||
{
|
Array.Copy(m_asset.Data, 0, destinationArray, 0, assetLength);
|
||||||
byte[] buffer2 = new byte[data.Length - 4];
|
Array.Copy(data, 0, destinationArray, assetLength, dataLength);
|
||||||
Array.Copy(data, 4, buffer2, 0, data.Length - 4);
|
m_asset.Data = destinationArray;
|
||||||
m_asset.Data = buffer2;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (dataLength > 4)
|
||||||
|
{
|
||||||
|
byte[] buffer2 = new byte[dataLength - 4];
|
||||||
|
Array.Copy(data, 4, buffer2, 0, dataLength - 4);
|
||||||
|
m_asset.Data = buffer2;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ourClient.SendConfirmXfer(xferID, packetID);
|
ourClient.SendConfirmXfer(xferID, packetID);
|
||||||
|
|
Loading…
Reference in New Issue