diff options
| author | Dan Engelbrecht <[email protected]> | 2022-04-05 12:32:52 +0200 |
|---|---|---|
| committer | Dan Engelbrecht <[email protected]> | 2022-04-05 12:32:52 +0200 |
| commit | c13f7695d7df327cad8ed40e58a7e9f12270960e (patch) | |
| tree | 16f3f23816219c661c18d23f27d2a06e596e1773 /zenstore/compactcas.cpp | |
| parent | Make index/log reading non-static member functions (diff) | |
| download | zen-c13f7695d7df327cad8ed40e58a7e9f12270960e.tar.xz zen-c13f7695d7df327cad8ed40e58a7e9f12270960e.zip | |
fix migration when entries is out of data file range
Diffstat (limited to 'zenstore/compactcas.cpp')
| -rw-r--r-- | zenstore/compactcas.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/zenstore/compactcas.cpp b/zenstore/compactcas.cpp index 174f59ac5..a28068d24 100644 --- a/zenstore/compactcas.cpp +++ b/zenstore/compactcas.cpp @@ -1153,13 +1153,14 @@ CasContainerStrategy::MigrateLegacyData(bool CleanSource) { Stopwatch Timer; const auto __ = MakeGuard([this, &LegacyDiskIndex, &Timer] { - ZEN_INFO("read store '{}' legacy index containing #{} entries in {}", + ZEN_INFO("read store '{}' legacy log containing #{} entries in {}", m_Config.RootDirectory / m_ContainerBaseName, LegacyDiskIndex.size(), NiceTimeSpanMs(Timer.GetElapsedTimeMs())); }); if (LegacyCasLog.Initialize()) { + uint64_t BlockFileSize = BlockFile.FileSize(); LegacyDiskIndex.reserve(LegacyCasLog.GetLogCount()); LegacyCasLog.Replay( [&](const LegacyCasDiskIndexEntry& Record) { @@ -1174,6 +1175,11 @@ CasContainerStrategy::MigrateLegacyData(bool CleanSource) ZEN_WARN("skipping invalid entry in '{}', reason: '{}'", LegacyLogPath, InvalidEntryReason); return; } + if (Record.Location.GetOffset() + Record.Location.GetSize() > BlockFileSize) + { + ZEN_WARN("skipping invalid entry in '{}', reason: location is outside of file", LegacyLogPath); + return; + } if (m_LocationMap.contains(Record.Key)) { return; |