Skip to content

Commit

Permalink
wal: fix crc mismatch crash bug
Browse files Browse the repository at this point in the history
  • Loading branch information
tangcong committed May 20, 2020
1 parent 732df43 commit 2227d80
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions wal/wal.go
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,14 @@ func ValidSnapshotEntries(lg *zap.Logger, walDir string) ([]walpb.Snapshot, erro
snaps = append(snaps, loadedSnap)
case stateType:
state = mustUnmarshalState(rec.Data)
case crcType:
crc := decoder.crc.Sum32()
// current crc of decoder must match the crc of the record.
// do no need to match 0 crc, since the decoder is a new one at this case.
if crc != 0 && rec.Validate(crc) != nil {
return nil,ErrCRCMismatch
}
decoder.updateCRC(rec.Crc)
}
}
// We do not have to read out all the WAL entries
Expand Down

0 comments on commit 2227d80

Please sign in to comment.