diff options
author | mvel <mvel@yandex-team.ru> | 2022-02-10 16:45:41 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:41 +0300 |
commit | 43f5a35593ebc9f6bcea619bb170394ea7ae468e (patch) | |
tree | e98df59de24d2ef7c77baed9f41e4875a2fef972 /library/cpp/blockcodecs/core | |
parent | bd30392c4cc92487950adc375c07adf52da1d592 (diff) | |
download | ydb-43f5a35593ebc9f6bcea619bb170394ea7ae468e.tar.gz |
Restoring authorship annotation for <mvel@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/blockcodecs/core')
-rw-r--r-- | library/cpp/blockcodecs/core/codecs.cpp | 46 | ||||
-rw-r--r-- | library/cpp/blockcodecs/core/codecs.h | 22 |
2 files changed, 34 insertions, 34 deletions
diff --git a/library/cpp/blockcodecs/core/codecs.cpp b/library/cpp/blockcodecs/core/codecs.cpp index 332b671221..21506e812b 100644 --- a/library/cpp/blockcodecs/core/codecs.cpp +++ b/library/cpp/blockcodecs/core/codecs.cpp @@ -64,9 +64,9 @@ namespace { TVector<TCodecPtr> Codecs; typedef THashMap<TStringBuf, ICodec*> TRegistry; TRegistry Registry; - - // SEARCH-8344: Global decompressed size limiter (to prevent remote DoS) - size_t MaxPossibleDecompressedLength = Max<size_t>(); + + // SEARCH-8344: Global decompressed size limiter (to prevent remote DoS) + size_t MaxPossibleDecompressedLength = Max<size_t>(); }; } @@ -94,25 +94,25 @@ void NBlockCodecs::RegisterAlias(TStringBuf from, TStringBuf to) { Singleton<TCodecFactory>()->Alias(from, to); } -void NBlockCodecs::SetMaxPossibleDecompressedLength(size_t maxPossibleDecompressedLength) { - Singleton<TCodecFactory>()->MaxPossibleDecompressedLength = maxPossibleDecompressedLength; -} - -size_t NBlockCodecs::GetMaxPossibleDecompressedLength() { - return Singleton<TCodecFactory>()->MaxPossibleDecompressedLength; -} - -size_t ICodec::GetDecompressedLength(const TData& in) const { - const size_t len = DecompressedLength(in); - - Y_ENSURE( - len <= NBlockCodecs::GetMaxPossibleDecompressedLength(), - "Attempt to decompress the block that is larger than maximum possible decompressed length, " - "see SEARCH-8344 for details. " - ); - return len; -} - +void NBlockCodecs::SetMaxPossibleDecompressedLength(size_t maxPossibleDecompressedLength) { + Singleton<TCodecFactory>()->MaxPossibleDecompressedLength = maxPossibleDecompressedLength; +} + +size_t NBlockCodecs::GetMaxPossibleDecompressedLength() { + return Singleton<TCodecFactory>()->MaxPossibleDecompressedLength; +} + +size_t ICodec::GetDecompressedLength(const TData& in) const { + const size_t len = DecompressedLength(in); + + Y_ENSURE( + len <= NBlockCodecs::GetMaxPossibleDecompressedLength(), + "Attempt to decompress the block that is larger than maximum possible decompressed length, " + "see SEARCH-8344 for details. " + ); + return len; +} + void ICodec::Encode(const TData& in, TBuffer& out) const { const size_t maxLen = MaxCompressedLength(in); @@ -121,7 +121,7 @@ void ICodec::Encode(const TData& in, TBuffer& out) const { } void ICodec::Decode(const TData& in, TBuffer& out) const { - const size_t len = GetDecompressedLength(in); + const size_t len = GetDecompressedLength(in); out.Reserve(len); out.Resize(Decompress(in, out.Data())); diff --git a/library/cpp/blockcodecs/core/codecs.h b/library/cpp/blockcodecs/core/codecs.h index 2fede1f029..9c93c00274 100644 --- a/library/cpp/blockcodecs/core/codecs.h +++ b/library/cpp/blockcodecs/core/codecs.h @@ -39,7 +39,7 @@ namespace NBlockCodecs { struct ICodec { virtual ~ICodec(); - // main interface + // main interface virtual size_t DecompressedLength(const TData& in) const = 0; virtual size_t MaxCompressedLength(const TData& in) const = 0; virtual size_t Compress(const TData& in, void* out) const = 0; @@ -47,7 +47,7 @@ namespace NBlockCodecs { virtual TStringBuf Name() const noexcept = 0; - // some useful helpers + // some useful helpers void Encode(const TData& in, TBuffer& out) const; void Decode(const TData& in, TBuffer& out) const; @@ -69,22 +69,22 @@ namespace NBlockCodecs { return out; } - private: - size_t GetDecompressedLength(const TData& in) const; + private: + size_t GetDecompressedLength(const TData& in) const; }; using TCodecPtr = THolder<ICodec>; const ICodec* Codec(const TStringBuf& name); - // some aux methods + // some aux methods typedef TVector<TStringBuf> TCodecList; TCodecList ListAllCodecs(); TString ListAllCodecsAsString(); - - // SEARCH-8344: Get the size of max possible decompressed block - size_t GetMaxPossibleDecompressedLength(); - // SEARCH-8344: Globally set the size of max possible decompressed block - void SetMaxPossibleDecompressedLength(size_t maxPossibleDecompressedLength); - + + // SEARCH-8344: Get the size of max possible decompressed block + size_t GetMaxPossibleDecompressedLength(); + // SEARCH-8344: Globally set the size of max possible decompressed block + void SetMaxPossibleDecompressedLength(size_t maxPossibleDecompressedLength); + } |