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/codecs.cpp | |
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/codecs.cpp')
-rw-r--r-- | library/cpp/blockcodecs/core/codecs.cpp | 46 |
1 files changed, 23 insertions, 23 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())); |