From 85d9f1c25562352002295875904170d2ec8fb667 Mon Sep 17 00:00:00 2001 From: Jan Date: Wed, 15 Jan 2025 00:47:01 +0100 Subject: [PATCH] fix: salsa20 encryption only initializes encryption with zone name of at max 31 characters length --- src/ZoneCommon/Zone/XChunk/AbstractSalsa20Processor.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ZoneCommon/Zone/XChunk/AbstractSalsa20Processor.cpp b/src/ZoneCommon/Zone/XChunk/AbstractSalsa20Processor.cpp index 1805c2a8..60451a69 100644 --- a/src/ZoneCommon/Zone/XChunk/AbstractSalsa20Processor.cpp +++ b/src/ZoneCommon/Zone/XChunk/AbstractSalsa20Processor.cpp @@ -21,7 +21,9 @@ uint8_t* AbstractSalsa20Processor::GetHashBlock(const int streamNumber) const void AbstractSalsa20Processor::InitStreams(const std::string& zoneName, const uint8_t* salsa20Key, const size_t keySize) const { - const auto zoneNameLength = zoneName.length(); + // Original buffer must have been 32 bytes because the zoneName can at most be 31 characters be long before being cut off + const auto zoneNameLength = std::min(zoneName.length(), 31u); + const size_t blockHashBufferSize = BLOCK_HASHES_COUNT * m_stream_count * SHA1_HASH_SIZE; assert(blockHashBufferSize % 4 == 0);