Merge pull request #3685 from citusdata/assert-shard-index-valid

Assert bounds checks on two array reads which rely on data not being out of bounds
pull/3686/head
Philip Dubé 2020-03-31 20:13:21 +00:00 committed by GitHub
commit 4552a990e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 0 deletions

View File

@ -373,6 +373,7 @@ TupleToDistributedResultFragment(TupleTableSlot *tupleSlot,
text *resultId = DatumGetTextP(slot_getattr(tupleSlot, 3, &isNull)); text *resultId = DatumGetTextP(slot_getattr(tupleSlot, 3, &isNull));
int64 rowCount = DatumGetInt64(slot_getattr(tupleSlot, 4, &isNull)); int64 rowCount = DatumGetInt64(slot_getattr(tupleSlot, 4, &isNull));
Assert(targetShardIndex < targetRelation->shardIntervalArrayLength);
ShardInterval *shardInterval = ShardInterval *shardInterval =
targetRelation->sortedShardIntervalArray[targetShardIndex]; targetRelation->sortedShardIntervalArray[targetShardIndex];
@ -443,6 +444,7 @@ ColocateFragmentsWithRelation(List *fragmentList, CitusTableCacheEntry *targetRe
{ {
int shardIndex = sourceFragment->targetShardIndex; int shardIndex = sourceFragment->targetShardIndex;
Assert(shardIndex < shardCount);
shardResultIdList[shardIndex] = lappend(shardResultIdList[shardIndex], shardResultIdList[shardIndex] = lappend(shardResultIdList[shardIndex],
sourceFragment->resultId); sourceFragment->resultId);
} }