aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2024-08-12 15:34:58 +0200
committerGitHub Enterprise <[email protected]>2024-08-12 15:34:58 +0200
commita95dd553c76184b36248ffbe7fdb5b033af53c64 (patch)
treed1eb77b292777ef5ba48831db5e84e21e944015b
parentmake oplog lsn unsigned (#107) (diff)
downloadzen-a95dd553c76184b36248ffbe7fdb5b033af53c64.tar.xz
zen-a95dd553c76184b36248ffbe7fdb5b033af53c64.zip
project store chunk requests that are out of range will be treated as not found (#108)
* project store chunk requests that are out of range will be treaded as not found * add chunkid to log
-rw-r--r--CHANGELOG.md1
-rw-r--r--src/zenserver/projectstore/projectstore.cpp26
2 files changed, 27 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ac20da127..941401b6d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -15,6 +15,7 @@
- Improvement: Catch exceptions in threaded work to avoid uncaught exception errors
- Improvement: Make oplog/project removal more robust
- Improvement: Made LSN number for project store oplog an unsigned 32 bit value at the top layer to increase range
+- Improvement: A request for an out of range project store chunk will now result in a "not found" status result
## 5.5.3
- Feature: New 'workspaces' service which allows a user to share a local folder via zenserver. A workspace can have mulitple workspace shares and they provie an HTTP API that is compatible with the project oplog HTTP API. Workspaces and shares are preserved between runs. Workspaces feature is disabled by default - enable with `--workspaces-enabled` option when launching zenserver.
diff --git a/src/zenserver/projectstore/projectstore.cpp b/src/zenserver/projectstore/projectstore.cpp
index 438943f75..a6f058cf4 100644
--- a/src/zenserver/projectstore/projectstore.cpp
+++ b/src/zenserver/projectstore/projectstore.cpp
@@ -3185,6 +3185,19 @@ ProjectStore::GetChunkRange(const std::string_view ProjectId,
Size = RawSize - Offset;
}
+ if (Size == 0)
+ {
+ return {
+ HttpResponseCode::NotFound,
+ fmt::format("Chunk request for range outside of chunk '{}/{}'. Request: Chunk: {}, Offset: {}, Size: {}, ChunkSize: {}",
+ ProjectId,
+ OplogId,
+ ChunkId,
+ Offset,
+ Size,
+ RawSize)};
+ }
+
if (AcceptType == ZenContentType::kBinary)
{
OutChunk = CompositeBuffer(Compressed.Decompress(Offset, Size));
@@ -3216,6 +3229,19 @@ ProjectStore::GetChunkRange(const std::string_view ProjectId,
{
Size = Chunk.GetSize() - Offset;
}
+
+ if (Size == 0)
+ {
+ return {HttpResponseCode::NotFound,
+ fmt::format("Chunk request for range outside of chunk '{}/{}'. Request: Chunk: {}, Offset: {}, Size: {}, ChunkSize: {}",
+ ProjectId,
+ OplogId,
+ ChunkId,
+ Offset,
+ Size,
+ Chunk.GetSize())};
+ }
+
OutChunk = CompositeBuffer(SharedBuffer(IoBuffer(std::move(Chunk), Offset, Size)));
}
else