blob: d9703bf1a318dae6a833c39b5cb3e5d6cf1ba50d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
// Copyright Epic Games, Inc. All Rights Reserved.
#include <zencore/compactbinaryutil.h>
#include <zencore/compress.h>
#include <zencore/filesystem.h>
namespace zen {
CbObject
ValidateAndReadCompactBinaryObject(const SharedBuffer&& Payload, CbValidateError& OutError)
{
if (Payload.GetSize() > 0)
{
if (OutError = ValidateCompactBinary(Payload.GetView(), CbValidateMode::Default); OutError == CbValidateError::None)
{
CbObject Object(Payload);
if (Object.GetView().GetSize() != Payload.GetSize())
{
OutError |= CbValidateError::OutOfBounds;
return {};
}
return Object;
}
}
return CbObject();
}
CbObject
ValidateAndReadCompactBinaryObject(const CompressedBuffer&& Payload, CbValidateError& OutError)
{
if (CompositeBuffer Decompressed = Payload.DecompressToComposite())
{
return ValidateAndReadCompactBinaryObject(std::move(Decompressed).Flatten(), OutError);
}
return CbObject();
}
} // namespace zen
|