From 7ef4fe3288bdc8ea9b0f89ae25e0c3c725480c2d Mon Sep 17 00:00:00 2001 From: AdamKorcz Date: Sat, 15 Jan 2022 15:45:22 +0000 Subject: [PATCH] raft: fix out-of-bounds in maybeAppend --- raft/log.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/raft/log.go b/raft/log.go index c94c41f77..82cf54aa2 100644 --- a/raft/log.go +++ b/raft/log.go @@ -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))