Skip to content

Commit 7f437bf

Browse files
authored
fix(database): prevented panic by validating middlePoint index (#1024)
Signed-off-by: Akhil Repala <arepala@blinklabs.io>
1 parent 0cef70e commit 7f437bf

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

database/immutable/immutable.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,13 @@ func (i *ImmutableDb) getChunkNamesFromPoint(
8282
for lowerBound <= upperBound {
8383
// Get chunk in the middle of the current bounds
8484
middlePoint := (lowerBound + upperBound) / 2
85+
if middlePoint < 0 || middlePoint >= len(chunkNames) {
86+
return nil, fmt.Errorf(
87+
"immutable DB: middlePoint %d out of bounds (chunkNames len=%d)",
88+
middlePoint,
89+
len(chunkNames),
90+
)
91+
}
8592
middleChunkName := chunkNames[middlePoint]
8693
middleSecondary, err := i.getChunkSecondaryIndex(middleChunkName)
8794
if err != nil {

0 commit comments

Comments
 (0)