Skip to content

[6.2][CAS] Fix an off-by-one error in CAS validation #10596

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion llvm/lib/CAS/OnDiskGraphDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,7 @@ Error OnDiskGraphDB::validate(bool Deep, HashingFuncT Hasher) const {
llvm_unreachable("already handled");
case TrieRecord::StorageKind::DataPool: {
auto DataRecord = DataRecordHandle::get(DataPool.beginData(D.Offset));
if (DataRecord.getTotalSize() + D.Offset.get() >= DataPool.size())
if (DataRecord.getTotalSize() + D.Offset.get() > DataPool.size())
return dataError("data record span passed the end of the data pool");
for (auto InternRef : DataRecord.getRefs()) {
auto Index = getIndexProxyFromRef(InternRef);
Expand Down
7 changes: 7 additions & 0 deletions llvm/test/tools/llvm-cas/validation.test
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
RUN: rm -rf %t
RUN: mkdir %t

# Ingest a blob which just fits inside the CAS data pool to make sure the validate passes.
RUN: truncate -s 7 %t/file
RUN: cat %t/file | \
RUN: llvm-cas --cas %t/cas --make-blob \
RUN: --data -
RUN: llvm-cas --cas %t/cas --validate --check-hash

RUN: llvm-cas --cas %t/cas --ingest %S/Inputs > %t/cas.id
RUN: llvm-cas --cas %t/cas --validate
RUN: llvm-cas --cas %t/cas --validate --check-hash
Expand Down