diff options
| author | Stefan Boberg <[email protected]> | 2025-10-06 22:33:00 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2025-10-06 22:33:00 +0200 |
| commit | 1383dbdc563d90c170ab30ba622ee44e2e37e723 (patch) | |
| tree | 59777db60000fe2ab2334f05776fb9ded4ca41fb /src/zencore/compactbinaryutil.cpp | |
| parent | Merge branch 'main' into sb/rpc-analysis (diff) | |
| parent | 5.7.6 (diff) | |
| download | zen-1383dbdc563d90c170ab30ba622ee44e2e37e723.tar.xz zen-1383dbdc563d90c170ab30ba622ee44e2e37e723.zip | |
Merge remote-tracking branch 'origin/main' into sb/rpc-analysis
Diffstat (limited to 'src/zencore/compactbinaryutil.cpp')
| -rw-r--r-- | src/zencore/compactbinaryutil.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/zencore/compactbinaryutil.cpp b/src/zencore/compactbinaryutil.cpp new file mode 100644 index 000000000..074bdaffd --- /dev/null +++ b/src/zencore/compactbinaryutil.cpp @@ -0,0 +1,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(std::move(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 |