Merge pull request #13603 from AdamKorcz/fuzz3

raft: fix out-of-bounds in maybeAppend
This commit is contained in:
Piotr Tabor 2022-01-17 16:11:46 +01:00 committed by GitHub
commit 22f142a9f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -95,6 +95,9 @@ func (l *raftLog) maybeAppend(index, logTerm, committed uint64, ents ...pb.Entry
l.logger.Panicf("entry %d conflict with committed entry [committed(%d)]", ci, l.committed)
default:
offset := index + 1
if ci-offset > uint64(len(ents)) {
l.logger.Panicf("index, %d, is out of range [%d]", ci-offset, len(ents))
}
l.append(ents[ci-offset:]...)
}
l.commitTo(min(committed, lastnewi))