Skip to content

Commit d0b0356

Browse files
[CAS] Fix an off-by-one error in CAS validation
Fix a false positive in invalid CAS detection that when the last data stored in CAS just fits inside the DataPool, validation is erroneously think the data stored pass the end of the storage. UnitTest for the edge case is very hard to contruct, where we might need to insert a lot of small and different objects into CAS to be just fit inside the CAS size. The bug was found by fuzzing the CAS, and can rely on basic fuzzing to find regressions in the future. rdar://150386374
1 parent 4b9d0c4 commit d0b0356

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

llvm/lib/CAS/OnDiskGraphDB.cpp

Lines changed: 1 addition & 1 deletion
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);

0 commit comments

Comments
 (0)