Module |
|
Header |
/Engine/Source/Runtime/Engine/Classes/Engine/NetSerialization.h |
Include |
#include "Engine/NetSerialization.h" |
===================== Safe TArray Serialization =====================
These are helper methods intended to make serializing TArrays safer in custom ::NetSerialize functions. These enforce max limits on array size, so that a malformed packet is not able to allocate an arbitrary amount of memory (E.g., a hacker serilizes a packet where a TArray size is of size MAX_int32, causing gigs of memory to be allocated for the TArray).
These should only need to be used when you are overriding ::NetSerialize on a UStruct via struct traits. When using default replication, TArray properties already have this built in security.
SafeNetSerializeTArray_Default - calls << operator to serialize the items in the array. SafeNetSerializeTArray_WithNetSerialize - calls NetSerialize to serialize the items in the array.
When saving, bOutSuccess will be set to false if the passed in array size exceeds to MaxNum template parameter.
Example:
FMyStruct { TArray
Do this instead: SafeNetSerializeTArray_Default<31>(Ar, MyFloats); SafeNetSerializeTArray_WithNetSerialize<31>(Ar, MyVectors, Map); } }