aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/zenremotestore/chunking/chunkingcontroller.cpp5
-rw-r--r--src/zenstore/cache/cachedisklayer.cpp12
2 files changed, 17 insertions, 0 deletions
diff --git a/src/zenremotestore/chunking/chunkingcontroller.cpp b/src/zenremotestore/chunking/chunkingcontroller.cpp
index 91ca18d10..0bb02d07f 100644
--- a/src/zenremotestore/chunking/chunkingcontroller.cpp
+++ b/src/zenremotestore/chunking/chunkingcontroller.cpp
@@ -5,6 +5,7 @@
#include <zencore/basicfile.h>
#include <zencore/compactbinaryutil.h>
#include <zencore/filesystem.h>
+#include <zencore/fmtutils.h>
#include <zencore/trace.h>
ZEN_THIRD_PARTY_INCLUDES_START
@@ -437,6 +438,10 @@ public:
{
const uint64_t BufferSize = std::min<uint64_t>(RawSize - Offset, BufferingSize);
MemoryView ChunkData = SourceBuffer.MakeView(BufferSize, Offset);
+ if (ChunkData.IsEmpty())
+ {
+ throw std::runtime_error(fmt::format("Invalid format. Expected to read {} bytes at {}", BufferSize, Offset));
+ }
FullHasher.Append(ChunkData);
ChunkHasher.Append(ChunkData);
BytesProcessed.fetch_add(BufferSize);
diff --git a/src/zenstore/cache/cachedisklayer.cpp b/src/zenstore/cache/cachedisklayer.cpp
index 4f0d412ec..46dfbd912 100644
--- a/src/zenstore/cache/cachedisklayer.cpp
+++ b/src/zenstore/cache/cachedisklayer.cpp
@@ -648,6 +648,13 @@ BucketManifestSerializer::ReadSidecarFile(RwLock::ExclusiveLockScope& B
while (RemainingEntryCount--)
{
const ManifestData* Entry = Sidecar.MakeView<ManifestData>(CurrentReadOffset);
+ if (Entry == nullptr)
+ {
+ ZEN_WARN("Failed to read sidecar file '{}'. Failed to read {} bytes at {}",
+ SidecarPath,
+ sizeof(ManifestData),
+ CurrentReadOffset);
+ }
CurrentReadOffset += sizeof(ManifestData);
if (auto It = Index.find(Entry->Key); It != Index.end())
@@ -1078,6 +1085,11 @@ ZenCacheDiskLayer::CacheBucket::ReadIndexFile(RwLock::ExclusiveLockScope&, const
while (RemainingEntryCount--)
{
const DiskIndexEntry* Entry = FileBuffer.MakeView<DiskIndexEntry>(CurrentReadOffset);
+ if (Entry == nullptr)
+ {
+ ZEN_WARN("skipping invalid entry in '{}', failed to read {} bytes at {}", IndexPath, sizeof(DiskIndexEntry), CurrentReadOffset);
+ continue;
+ }
CurrentReadOffset += sizeof(DiskIndexEntry);
if (!cache::impl::ValidateCacheBucketIndexEntry(*Entry, InvalidEntryReason))