diff options
| author | Stefan Boberg <[email protected]> | 2021-09-16 13:11:11 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2021-09-16 13:11:25 +0200 |
| commit | 1983dc5f3292afa0b1b2b991428a91f111d34b8c (patch) | |
| tree | 16989f2d7a335ee67e121b452676d8919c3c1b61 | |
| parent | Fixed misleading comment for `CbAttachment::AsCompositeBinary` (diff) | |
| download | zen-1983dc5f3292afa0b1b2b991428a91f111d34b8c.tar.xz zen-1983dc5f3292afa0b1b2b991428a91f111d34b8c.zip | |
Fixed some unreferenced variable warnings (why don't we get these in sln builds?). Also added size verification to certain payloads
| -rw-r--r-- | zenserver-test/zenserver-test.cpp | 2 | ||||
| -rw-r--r-- | zenserver/compute/apply.cpp | 30 |
2 files changed, 22 insertions, 10 deletions
diff --git a/zenserver-test/zenserver-test.cpp b/zenserver-test/zenserver-test.cpp index 213648319..e68161ccf 100644 --- a/zenserver-test/zenserver-test.cpp +++ b/zenserver-test/zenserver-test.cpp @@ -194,6 +194,8 @@ private: size_t rv = http_parser_execute(&m_HttpParser, &m_HttpParserSettings, (const char*)m_ResponseBuffer.data(), Bytes); + ZEN_UNUSED(rv); + if (m_HttpParser.http_errno != 0) { // Something bad! diff --git a/zenserver/compute/apply.cpp b/zenserver/compute/apply.cpp index 7b76bb80b..2c3243655 100644 --- a/zenserver/compute/apply.cpp +++ b/zenserver/compute/apply.cpp @@ -659,16 +659,21 @@ HttpFunctionService::ExecAction(const WorkerDesc& Worker, CbObject Action) { CbObjectView ExecEntry = It.AsObjectView(); - std::string_view Name = ExecEntry["name"sv].AsString(); - const IoHash Hash = ExecEntry["hash"sv].AsHash(); - const uint64_t Size = ExecEntry["size"sv].AsUInt64(); + std::string_view Name = ExecEntry["name"sv].AsString(); + const IoHash ChunkHash = ExecEntry["hash"sv].AsHash(); + const uint64_t Size = ExecEntry["size"sv].AsUInt64(); std::filesystem::path FilePath{SandboxPath / Name}; - IoBuffer DataBuffer = m_CasStore.FindChunk(Hash); + IoBuffer DataBuffer = m_CasStore.FindChunk(ChunkHash); if (!DataBuffer) { - throw std::runtime_error("worker CAS chunk '{}' missing"_format(Hash)); + throw std::runtime_error("worker CAS chunk '{}' missing"_format(ChunkHash)); + } + + if (DataBuffer.Size() != Size) + { + throw std::runtime_error("worker CAS chunk '{}' size: {}, action spec expected {}"_format(ChunkHash, DataBuffer.Size(), Size)); } zen::WriteFile(FilePath, DataBuffer); @@ -685,16 +690,21 @@ HttpFunctionService::ExecAction(const WorkerDesc& Worker, CbObject Action) { CbObjectView FileEntry = It.AsObjectView(); - std::string_view Name = FileEntry["name"sv].AsString(); - const IoHash Hash = FileEntry["hash"sv].AsHash(); - const uint64_t Size = FileEntry["size"sv].AsUInt64(); + std::string_view Name = FileEntry["name"sv].AsString(); + const IoHash ChunkHash = FileEntry["hash"sv].AsHash(); + const uint64_t Size = FileEntry["size"sv].AsUInt64(); std::filesystem::path FilePath{SandboxPath / Name}; - IoBuffer DataBuffer = m_CasStore.FindChunk(Hash); + IoBuffer DataBuffer = m_CasStore.FindChunk(ChunkHash); if (!DataBuffer) { - throw std::runtime_error("worker CAS chunk '{}' missing"_format(Hash)); + throw std::runtime_error("worker CAS chunk '{}' missing"_format(ChunkHash)); + } + + if (DataBuffer.Size() != Size) + { + throw std::runtime_error("worker CAS chunk '{}' size: {}, action spec expected {}"_format(ChunkHash, DataBuffer.Size(), Size)); } zen::WriteFile(FilePath, DataBuffer); |