diff options
| author | Dan Engelbrecht <[email protected]> | 2024-11-21 11:38:06 +0100 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2024-11-21 11:38:06 +0100 |
| commit | 387cecf89ec25acc11f6d090a0f5cabf6fdfdf0f (patch) | |
| tree | f377f13902b94ebf4b9653cfdd725bbde996a9da /src | |
| parent | memory/string support cleanup and additions (#220) (diff) | |
| download | zen-387cecf89ec25acc11f6d090a0f5cabf6fdfdf0f.tar.xz zen-387cecf89ec25acc11f6d090a0f5cabf6fdfdf0f.zip | |
fix crash on corrupt oplog block (#223)
* bail attachment import on corrupt attachment block
* changelog
Diffstat (limited to 'src')
| -rw-r--r-- | src/zenserver/projectstore/remoteprojectstore.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/zenserver/projectstore/remoteprojectstore.cpp b/src/zenserver/projectstore/remoteprojectstore.cpp index 3c44432b5..970cb19fd 100644 --- a/src/zenserver/projectstore/remoteprojectstore.cpp +++ b/src/zenserver/projectstore/remoteprojectstore.cpp @@ -145,6 +145,12 @@ LogRemoteStoreStatsDetails(const RemoteProjectStore::Stats& Stats) bool IterateBlock(const SharedBuffer& BlockPayload, std::function<void(CompressedBuffer&& Chunk, const IoHash& AttachmentHash)> Visitor) { + ZEN_ASSERT(BlockPayload); + if (BlockPayload.GetSize() < 1) + { + return false; + } + MemoryView BlockView = BlockPayload.GetView(); const uint8_t* ReadPtr = reinterpret_cast<const uint8_t*>(BlockView.GetData()); uint32_t NumberSize; @@ -2619,12 +2625,22 @@ LoadOplog(CidStore& ChunkStore, IoHash RawHash; uint64_t RawSize; SharedBuffer BlockPayload = CompressedBuffer::FromCompressed(SharedBuffer(Bytes), RawHash, RawSize).Decompress(); + if (!BlockPayload) + { + ReportMessage(OptionalContext, + fmt::format("Block attachment {} is malformed, can't parse as compressed binary", BlockHash)); + RemoteResult.SetError(gsl::narrow<int32_t>(HttpResponseCode::InternalServerError), + fmt::format("Block attachment {} is malformed, can't parse as compressed binary", BlockHash), + {}); + return; + } if (RawHash != BlockHash) { ReportMessage(OptionalContext, fmt::format("Block attachment {} has mismatching raw hash ({})", BlockHash, RawHash)); RemoteResult.SetError(gsl::narrow<int32_t>(HttpResponseCode::InternalServerError), fmt::format("Block attachment {} has mismatching raw hash ({})", BlockHash, RawHash), {}); + return; } bool StoreChunksOK = IterateBlock( |