From 8bf4e0eaa5298e235d3606987736e5d4e6383fa8 Mon Sep 17 00:00:00 2001 From: Roman Nozdrin Date: Thu, 14 Apr 2022 11:53:09 +0000 Subject: [PATCH] MCOL-5050 EM Index dbroot container out-of-bound access checks doing EM deletes --- versioning/BRM/extentmap.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/versioning/BRM/extentmap.cpp b/versioning/BRM/extentmap.cpp index 0f8d32a88..fab238286 100644 --- a/versioning/BRM/extentmap.cpp +++ b/versioning/BRM/extentmap.cpp @@ -527,12 +527,19 @@ ExtentMapIndexFindResult ExtentMapIndexImpl::search3dLayer(PartitionIndexContain void ExtentMapIndexImpl::deleteDbRoot(const DBRootT dbroot) { auto& extMapIndex = *get(); + if (dbroot >= extMapIndex.size()) + return; // nothing to delete extMapIndex[dbroot].clear(); } void ExtentMapIndexImpl::deleteOID(const DBRootT dbroot, const OID_t oid) { auto& extMapIndex = *get(); + // nothing to delete + if (dbroot >= extMapIndex.size()) + return; + if (extMapIndex[dbroot].empty()) + return; auto oidsIter = extMapIndex[dbroot].find(oid); // Nothing to delete. Might be a sign of a problem. if (oidsIter == extMapIndex[dbroot].end()) @@ -544,6 +551,10 @@ void ExtentMapIndexImpl::deleteEMEntry(const EMEntry& emEntry, const ExtentMapId { // find partition auto& extMapIndex = *get(); + if (emEntry.dbRoot >= extMapIndex.size()) + return; + if (extMapIndex[emEntry.dbRoot].empty()) + return; auto oidsIter = extMapIndex[emEntry.dbRoot].find(emEntry.fileID); if (oidsIter == extMapIndex[emEntry.dbRoot].end()) return; @@ -1646,7 +1657,6 @@ void ExtentMap::loadVersion4or5(T* in, bool upgradeV4ToV5) } growEMShmseg(nrows); - growEMIndexShmseg(ExtentMapIndexImpl::estimateEMIndexSize(emNumElements)); } size_t progress = 0, writeSize = emNumElements * sizeof(EMEntry);