feat: added checks for size of payload
This commit is contained in:
@@ -6,17 +6,19 @@ namespace Ragon.Core;
|
||||
public class EntityProperty
|
||||
{
|
||||
public int Size { get; set; }
|
||||
public int Capacity { get; set; }
|
||||
public bool IsDirty { get; private set; }
|
||||
public bool IsFixed { get; private set; }
|
||||
private byte[] _data;
|
||||
|
||||
public EntityProperty(int size, bool isFixed)
|
||||
{
|
||||
_data = new byte[512];
|
||||
|
||||
Capacity = 512;
|
||||
Size = size;
|
||||
IsFixed = isFixed;
|
||||
IsDirty = true;
|
||||
|
||||
_data = new byte[Capacity];
|
||||
}
|
||||
|
||||
public ReadOnlySpan<byte> Read()
|
||||
|
||||
@@ -160,11 +160,19 @@ namespace Ragon.Core
|
||||
if (_serializer.ReadBool())
|
||||
{
|
||||
var property = ent.Properties[i];
|
||||
var size = property.Size;
|
||||
if (!property.IsFixed)
|
||||
property.Size = _serializer.ReadUShort();
|
||||
size = _serializer.ReadUShort();
|
||||
|
||||
var propertyPayload = _serializer.ReadData(property.Size);
|
||||
if (size > property.Capacity)
|
||||
{
|
||||
_logger.Warn($"Property {i} payload too large, size: {size}");
|
||||
continue;
|
||||
}
|
||||
|
||||
var propertyPayload = _serializer.ReadData(size);
|
||||
property.Write(ref propertyPayload);
|
||||
property.Size = size;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user