Skip to content

Commit f3ac3ff

Browse files
authored
Merge pull request #10596 from cachemeifyoucan/eng/PR-150386374-stable
[6.2][CAS] Fix an off-by-one error in CAS validation
2 parents 593f1bf + 627a2b8 commit f3ac3ff

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

llvm/lib/CAS/OnDiskGraphDB.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,7 @@ Error OnDiskGraphDB::validate(bool Deep, HashingFuncT Hasher) const {
966966
llvm_unreachable("already handled");
967967
case TrieRecord::StorageKind::DataPool: {
968968
auto DataRecord = DataRecordHandle::get(DataPool.beginData(D.Offset));
969-
if (DataRecord.getTotalSize() + D.Offset.get() >= DataPool.size())
969+
if (DataRecord.getTotalSize() + D.Offset.get() > DataPool.size())
970970
return dataError("data record span passed the end of the data pool");
971971
for (auto InternRef : DataRecord.getRefs()) {
972972
auto Index = getIndexProxyFromRef(InternRef);

llvm/test/tools/llvm-cas/validation.test

+7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
RUN: rm -rf %t
22
RUN: mkdir %t
33

4+
# Ingest a blob which just fits inside the CAS data pool to make sure the validate passes.
5+
RUN: truncate -s 7 %t/file
6+
RUN: cat %t/file | \
7+
RUN: llvm-cas --cas %t/cas --make-blob \
8+
RUN: --data -
9+
RUN: llvm-cas --cas %t/cas --validate --check-hash
10+
411
RUN: llvm-cas --cas %t/cas --ingest %S/Inputs > %t/cas.id
512
RUN: llvm-cas --cas %t/cas --validate
613
RUN: llvm-cas --cas %t/cas --validate --check-hash

0 commit comments

Comments
 (0)