diff options
| author | Stefan Boberg <[email protected]> | 2021-08-20 13:51:39 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2021-08-20 13:51:39 +0200 |
| commit | d88262efac17b956600c85a2ba5e70c66937eb96 (patch) | |
| tree | 52352a8183bd1e528d7380b82926fe13bfbdabeb /zencore/compactbinary.cpp | |
| parent | Renamed CompactBinaryAttachment to ObjectAttachment to mimic UE (see CL16510518) (diff) | |
| download | zen-d88262efac17b956600c85a2ba5e70c66937eb96.tar.xz zen-d88262efac17b956600c85a2ba5e70c66937eb96.zip | |
CL16570338: CompactBinary: Added validation to LoadCompactBinary and removed asserts from the other load functions
Diffstat (limited to 'zencore/compactbinary.cpp')
| -rw-r--r-- | zencore/compactbinary.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/zencore/compactbinary.cpp b/zencore/compactbinary.cpp index 62c60418c..73ca9832f 100644 --- a/zencore/compactbinary.cpp +++ b/zencore/compactbinary.cpp @@ -2,6 +2,7 @@ #include "zencore/compactbinary.h" +#include "zencore/compactbinaryvalidation.h" #include <zencore/endian.h> #include <zencore/stream.h> #include <zencore/trace.h> @@ -1072,7 +1073,10 @@ LoadCompactBinary(BinaryReader& Ar, BufferAllocator Allocator) { break; } - ZEN_ASSERT(FieldSize > 0, "Failed to load from invalid compact binary data."); + if (FieldSize == 0) + { + return CbField(); + } } // Allocate the buffer, copy the header, and read the remainder of the field. @@ -1085,6 +1089,10 @@ LoadCompactBinary(BinaryReader& Ar, BufferAllocator Allocator) { Ar.Read(View.GetData(), View.GetSize()); } + if (ValidateCompactBinary(Buffer, CbValidateMode::Default) != CbValidateError::None) + { + return CbField(); + } return CbField(SharedBuffer(std::move(Buffer))); } |